The method allows to retrieve items according to the given parameters. 此方法允许根据给定的参数获取监控项。

    (object) Parameters defining the desired output. (object) 参数定义期望输出。

    The method supports the following parameters. 此方法支持如下参数。

    Finding items by key 根据key查找监控项

    Retrieve all items from host with ID “10084” that have the word “system” in the key and sort them by name. 从ID为“10084”的主机获取key带有“system”的监控项,并以名称排序。

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "itemid": "23298",
    6. "type": "0",
    7. "snmp_community": "",
    8. "snmp_oid": "",
    9. "hostid": "10084",
    10. "name": "Context switches per second",
    11. "key_": "system.cpu.switches",
    12. "delay": "1m",
    13. "history": "7d",
    14. "trends": "365d",
    15. "lastvalue": "2552",
    16. "lastclock": "1351090998",
    17. "prevvalue": "2641",
    18. "state": "0",
    19. "status": "0",
    20. "value_type": "3",
    21. "trapper_hosts": "",
    22. "units": "sps",
    23. "snmpv3_securityname": "",
    24. "snmpv3_securitylevel": "0",
    25. "snmpv3_authpassphrase": "",
    26. "snmpv3_privpassphrase": "",
    27. "snmpv3_authprotocol": "0",
    28. "snmpv3_privprotocol": "0",
    29. "snmpv3_contextname": "",
    30. "error": "",
    31. "lastlogsize": "0",
    32. "logtimefmt": "",
    33. "templateid": "22680",
    34. "valuemapid": "0",
    35. "params": "",
    36. "ipmi_sensor": "",
    37. "authtype": "0",
    38. "username": "",
    39. "password": "",
    40. "publickey": "",
    41. "privatekey": "",
    42. "mtime": "0",
    43. "lastns": "564054253",
    44. "flags": "0",
    45. "interfaceid": "1",
    46. "port": "",
    47. "description": "",
    48. "inventory_link": "0",
    49. "lifetime": "0s",
    50. "evaltype": "0",
    51. "jmx_endpoint": "",
    52. "master_itemid": "0",
    53. "timeout": "3s",
    54. "url": "",
    55. "query_fields": [],
    56. "posts": "",
    57. "status_codes": "200",
    58. "follow_redirects": "1",
    59. "post_type": "0",
    60. "http_proxy": "",
    61. "headers": [],
    62. "retrieve_mode": "0",
    63. "request_method": "1",
    64. "output_format": "0",
    65. "ssl_cert_file": "",
    66. "ssl_key_file": "",
    67. "ssl_key_password": "",
    68. "verify_peer": "0",
    69. "verify_host": "0",
    70. "allow_traps": "0"
    71. },
    72. {
    73. "itemid": "23299",
    74. "type": "0",
    75. "snmp_community": "",
    76. "snmp_oid": "",
    77. "hostid": "10084",
    78. "name": "CPU $2 time",
    79. "key_": "system.cpu.util[,idle]",
    80. "delay": "1m",
    81. "history": "7d",
    82. "trends": "365d",
    83. "lastvalue": "86.031879",
    84. "lastclock": "1351090999",
    85. "prevvalue": "85.306944",
    86. "state": "0",
    87. "status": "0",
    88. "value_type": "0",
    89. "trapper_hosts": "",
    90. "units": "%",
    91. "snmpv3_securityname": "",
    92. "snmpv3_securitylevel": "0",
    93. "snmpv3_authpassphrase": "",
    94. "snmpv3_privpassphrase": "",
    95. "snmpv3_authprotocol": "0",
    96. "snmpv3_privprotocol": "0",
    97. "snmpv3_contextname": "",
    98. "error": "",
    99. "lastlogsize": "0",
    100. "logtimefmt": "",
    101. "templateid": "17354",
    102. "valuemapid": "0",
    103. "params": "",
    104. "ipmi_sensor": "",
    105. "authtype": "0",
    106. "username": "",
    107. "password": "",
    108. "publickey": "",
    109. "privatekey": "",
    110. "mtime": "0",
    111. "lastns": "564256864",
    112. "flags": "0",
    113. "interfaceid": "1",
    114. "port": "",
    115. "description": "The time the CPU has spent doing nothing.",
    116. "inventory_link": "0",
    117. "lifetime": "0s",
    118. "evaltype": "0",
    119. "jmx_endpoint": "",
    120. "master_itemid": "0",
    121. "timeout": "3s",
    122. "url": "",
    123. "query_fields": [],
    124. "posts": "",
    125. "status_codes": "200",
    126. "follow_redirects": "1",
    127. "post_type": "0",
    128. "http_proxy": "",
    129. "headers": [],
    130. "retrieve_mode": "0",
    131. "request_method": "1",
    132. "output_format": "0",
    133. "ssl_cert_file": "",
    134. "ssl_key_file": "",
    135. "ssl_key_password": "",
    136. "verify_host": "0",
    137. "allow_traps": "0"
    138. },
    139. {
    140. "type": "0",
    141. "snmp_community": "",
    142. "snmp_oid": "",
    143. "hostid": "10084",
    144. "name": "CPU $2 time",
    145. "key_": "system.cpu.util[,interrupt]",
    146. "history": "7d",
    147. "trends": "365d",
    148. "lastvalue": "0.008389",
    149. "lastclock": "1351091000",
    150. "prevvalue": "0.000000",
    151. "state": "0",
    152. "status": "0",
    153. "value_type": "0",
    154. "trapper_hosts": "",
    155. "units": "%",
    156. "snmpv3_securityname": "",
    157. "snmpv3_securitylevel": "0",
    158. "snmpv3_authpassphrase": "",
    159. "snmpv3_privpassphrase": "",
    160. "snmpv3_authprotocol": "0",
    161. "snmpv3_privprotocol": "0",
    162. "snmpv3_contextname": "",
    163. "error": "",
    164. "lastlogsize": "0",
    165. "logtimefmt": "",
    166. "templateid": "22671",
    167. "valuemapid": "0",
    168. "params": "",
    169. "ipmi_sensor": "",
    170. "authtype": "0",
    171. "username": "",
    172. "password": "",
    173. "publickey": "",
    174. "privatekey": "",
    175. "mtime": "0",
    176. "lastns": "564661387",
    177. "flags": "0",
    178. "interfaceid": "1",
    179. "port": "",
    180. "description": "The amount of time the CPU has been servicing hardware interrupts.",
    181. "inventory_link": "0",
    182. "lifetime": "0s",
    183. "evaltype": "0",
    184. "jmx_endpoint": "",
    185. "master_itemid": "0",
    186. "timeout": "3s",
    187. "url": "",
    188. "query_fields": [],
    189. "posts": "",
    190. "status_codes": "200",
    191. "follow_redirects": "1",
    192. "post_type": "0",
    193. "http_proxy": "",
    194. "headers": [],
    195. "retrieve_mode": "0",
    196. "request_method": "1",
    197. "output_format": "0",
    198. "ssl_cert_file": "",
    199. "ssl_key_file": "",
    200. "ssl_key_password": "",
    201. "verify_peer": "0",
    202. "verify_host": "0",
    203. "allow_traps": "0"
    204. }
    205. ],
    206. "id": 1
    207. }

    Finding dependent items by key 根据key查找依赖监控项

    Retrieve all dependent items from host with ID “10116” that have the word “apache” in the key. 从ID未“10116”的主机中获取key名包含“apache”的依赖监控项。

    Request:

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "itemid": "25550",
    6. "type": "18",
    7. "snmp_community": "",
    8. "snmp_oid": "",
    9. "hostid": "10116",
    10. "name": "Days",
    11. "key_": "apache.status.uptime.days",
    12. "delay": "",
    13. "history": "90d",
    14. "trends": "365d",
    15. "status": "0",
    16. "value_type": "3",
    17. "trapper_hosts": "",
    18. "units": "",
    19. "snmpv3_securityname": "",
    20. "snmpv3_securitylevel": "0",
    21. "snmpv3_authpassphrase": "",
    22. "snmpv3_privpassphrase": "",
    23. "formula": "",
    24. "error": "",
    25. "lastlogsize": "0",
    26. "logtimefmt": "",
    27. "templateid": "0",
    28. "valuemapid": "0",
    29. "params": "",
    30. "ipmi_sensor": "",
    31. "authtype": "0",
    32. "username": "",
    33. "password": "",
    34. "publickey": "",
    35. "privatekey": "",
    36. "mtime": "0",
    37. "flags": "0",
    38. "interfaceid": "0",
    39. "port": "",
    40. "description": "",
    41. "inventory_link": "0",
    42. "lifetime": "30d",
    43. "snmpv3_authprotocol": "0",
    44. "snmpv3_privprotocol": "0",
    45. "state": "0",
    46. "snmpv3_contextname": "",
    47. "evaltype": "0",
    48. "master_itemid": "25545",
    49. "jmx_endpoint": "",
    50. "timeout": "3s",
    51. "url": "",
    52. "query_fields": [],
    53. "posts": "",
    54. "status_codes": "200",
    55. "follow_redirects": "1",
    56. "post_type": "0",
    57. "http_proxy": "",
    58. "headers": [],
    59. "retrieve_mode": "0",
    60. "request_method": "1",
    61. "output_format": "0",
    62. "ssl_cert_file": "",
    63. "ssl_key_file": "",
    64. "ssl_key_password": "",
    65. "verify_peer": "0",
    66. "verify_host": "0",
    67. "allow_traps": "0",
    68. "lastclock": "0",
    69. "lastns": "0",
    70. "lastvalue": "0",
    71. "prevvalue": "0"
    72. },
    73. {
    74. "itemid": "25555",
    75. "snmp_community": "",
    76. "snmp_oid": "",
    77. "hostid": "10116",
    78. "name": "Hours",
    79. "key_": "apache.status.uptime.hours",
    80. "history": "90d",
    81. "trends": "365d",
    82. "status": "0",
    83. "value_type": "3",
    84. "trapper_hosts": "",
    85. "units": "",
    86. "snmpv3_securityname": "",
    87. "snmpv3_securitylevel": "0",
    88. "snmpv3_authpassphrase": "",
    89. "snmpv3_privpassphrase": "",
    90. "formula": "",
    91. "error": "",
    92. "lastlogsize": "0",
    93. "logtimefmt": "",
    94. "templateid": "0",
    95. "valuemapid": "0",
    96. "params": "",
    97. "ipmi_sensor": "",
    98. "authtype": "0",
    99. "username": "",
    100. "password": "",
    101. "publickey": "",
    102. "privatekey": "",
    103. "mtime": "0",
    104. "flags": "0",
    105. "interfaceid": "0",
    106. "port": "",
    107. "description": "",
    108. "inventory_link": "0",
    109. "lifetime": "30d",
    110. "snmpv3_authprotocol": "0",
    111. "snmpv3_privprotocol": "0",
    112. "state": "0",
    113. "snmpv3_contextname": "",
    114. "evaltype": "0",
    115. "master_itemid": "25545",
    116. "jmx_endpoint": "",
    117. "timeout": "3s",
    118. "url": "",
    119. "query_fields": [],
    120. "posts": "",
    121. "status_codes": "200",
    122. "follow_redirects": "1",
    123. "post_type": "0",
    124. "http_proxy": "",
    125. "headers": [],
    126. "retrieve_mode": "0",
    127. "request_method": "1",
    128. "output_format": "0",
    129. "ssl_cert_file": "",
    130. "ssl_key_file": "",
    131. "ssl_key_password": "",
    132. "verify_peer": "0",
    133. "verify_host": "0",
    134. "allow_traps": "0",
    135. "lastclock": "0",
    136. "lastns": "0",
    137. "lastvalue": "0",
    138. "prevvalue": "0"
    139. }
    140. ],
    141. "id": 1
    142. }

    Find HTTP agent item 查找HTTP agent 监控项

    Find HTTP agent item with post body type XML for specific host id. 根据定义的主机id来查找带有XML post报文类型的监控项。

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "itemid": "28252",
    6. "type": "19",
    7. "snmp_community": "",
    8. "snmp_oid": "",
    9. "hostid": "10255",
    10. "name": "template item",
    11. "key_": "ti",
    12. "delay": "30s",
    13. "history": "90d",
    14. "trends": "365d",
    15. "status": "0",
    16. "value_type": "3",
    17. "trapper_hosts": "",
    18. "units": "",
    19. "snmpv3_securityname": "",
    20. "snmpv3_securitylevel": "0",
    21. "snmpv3_authpassphrase": "",
    22. "snmpv3_privpassphrase": "",
    23. "formula": "",
    24. "error": "",
    25. "lastlogsize": "0",
    26. "logtimefmt": "",
    27. "templateid": "0",
    28. "valuemapid": "0",
    29. "params": "",
    30. "ipmi_sensor": "",
    31. "authtype": "0",
    32. "username": "",
    33. "password": "",
    34. "publickey": "",
    35. "privatekey": "",
    36. "mtime": "0",
    37. "flags": "0",
    38. "interfaceid": "0",
    39. "port": "",
    40. "description": "",
    41. "inventory_link": "0",
    42. "lifetime": "30d",
    43. "snmpv3_authprotocol": "0",
    44. "snmpv3_privprotocol": "0",
    45. "state": "0",
    46. "snmpv3_contextname": "",
    47. "evaltype": "0",
    48. "jmx_endpoint": "",
    49. "master_itemid": "0",
    50. "timeout": "3s",
    51. "url": "localhost",
    52. "query_fields": [
    53. {
    54. "mode": "xml"
    55. }
    56. ],
    57. "posts": "<body>\r\n<![CDATA[{$MACRO}<foo></bar>]]>\r\n</body>",
    58. "status_codes": "200",
    59. "follow_redirects": "0",
    60. "post_type": "3",
    61. "http_proxy": "",
    62. "headers": [],
    63. "retrieve_mode": "1",
    64. "request_method": "3",
    65. "output_format": "0",
    66. "ssl_cert_file": "",
    67. "ssl_key_file": "",
    68. "ssl_key_password": "",
    69. "verify_peer": "0",
    70. "verify_host": "0",
    71. "allow_traps": "0",
    72. "lastclock": "0",
    73. "lastns": "0",
    74. "lastvalue": "0",
    75. "prevvalue": "0"
    76. }
    77. ],
    78. "id": 3

    CItem::get() in frontends/php/include/classes/api/services/CItem.php.