integer/array item.get(object parameters)
このメソッドを使用すると、指定されたパラメーターに従ってアイテムを取得できます。
このメソッドはどのタイプのユーザーでも利用可能です。このメソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。詳しくはユーザーの役割を参照してください。
(object)
目的の出力を定義するパラメーター。
このメソッドは、次のパラメーターをサポートしています。
パラメータ | タイプ | 説明 |
---|---|---|
itemids | string/array | 指定された ID を持つアイテムのみを返します |
groupids | string/array | 指定されたグループのホストに属するアイテムのみを返します |
templateids | string/array | 指定されたテンプレートに属するアイテムのみを返します |
hostids | string/array | 指定されたホストに属するアイテムのみを返します |
proxyids | string/array | 指定されたプロキシによって監視されているアイテムのみを返します |
interfaceids | string/array | 指定されたホスト インターフェイスを使用するアイテムのみを返します |
graphids | string/array | 指定されたグラフで使用されているアイテムのみを返します |
triggerids | string/array | 指定されたトリガーで使用されるアイテムのみを返します |
webitems | flag | 結果に Web アイテムを含めます |
inherited | boolean | "true"に設定すると、テンプレートから継承されたアイテムのみが返されます。 |
templated | boolean | "true"に設定すると、テンプレートに属するアイテムのみが返されます。 |
monitored | boolean | "true"に設定すると、監視対象ホストに属する有効なアイテムのみが返されます。 |
group | string | 指定された名前のグループに属するアイテムのみを返します |
host | string | 指定された名前のホストに属するアイテムのみを返します |
evaltype | integer | タグ検索のルール 使用可能な値: 0 - (デフォルト) And/Or 2 - Or |
tags | array of objects | 指定されたタグを持つアイテムのみを返します。タグによる完全一致と、演算子の値に応じたタグ値による大文字と小文字の区別または区別なしの検索。 フォーマット: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...] 空の配列はすべての項目を返します。 使用可能な演算子: 0 - (デフォルト) Like 1 - 等しい 2 - Not Like 3 - 等しくない 4 - 存在する 5 - 存在しない |
with_triggers | boolean | "true"に設定すると、トリガーで使用されるアイテムのみが返されます。 |
selectHosts | query | 項目が属するホストの配列を持つhostsプロパティを返します。 |
selectInterfaces | query | アイテムが使用するホスト インターフェースの配列を含むinterfacesプロパティを返します |
selectTriggers | query | アイテムが使用されているトリガーを含むtriggersプロパティを返します。count をサポートします。 |
selectGraphs | query | アイテムを含むグラフのgraphsプロパティを返します。count をサポートします。 |
selectDiscoveryRule | query | アイテムを作成した LLD ルールを含む discoveryRule プロパティを返します。 |
selectItemDiscovery | query | アイテムディスカバリオブジェクトを含む itemDiscovery プロパティを返します。 |
アイテムディスカバリオブジェクトは、アイテムをそのアイテムの作成元のアイテムプロトタイプにリンクします。 以下のプロパティがあります。 itemdiscoveryid - (string) アイテムディスカバリのIDitemid - (string) 発見されたアイテムの IDparent_itemid - (string) アイテムが作成されたアイテムプロトタイプの IDkey_ - (string) アイテム プロトタイプのキーlastcheck - (timestamp) アイテムが最後に発見された時間ts_delete - (timestamp) 検出されなくなったアイテムが削除される時刻 | ||
selectPreprocessing | query | アイテムの自演処理オプションを含むpreprocessingプロパティを返します。 次のプロパティがあります。 type - (string) 事前処理オプション タイプ:1 - カスタム乗数。 2 - 右トリム。 3 - 左トリム。 4 - トリム; 5 - 正規表現マッチング。 6 - ブール値から 10 進数。 7 - 8 進数から 10 進数。 8 - 16 進数から 10 進数。 9 - 簡単な変更。 10 - 1 秒ごとに変化します。 11 - XML XPath 12 - JSONPath 13 - 範囲内。 14 - 正規表現に一致。 15 - 正規表現と一致しません。 16 - JSON のエラーをチェックします。 17 - XML のエラーをチェックします。 18 - 正規表現を使用してエラーをチェックします。 19 - 変更せずに破棄します。 20 - ハートビートで変更されていないものを破棄します。 21 - JavaScript; 22 - プロメテウス パターン。 23 - プロメテウスから JSON へ。 24 - CSV から JSON; 25 - 交換; 26 - サポートされていない値をチェックします。 27 - XML から JSON へ。 params - (string) 前処理オプションで使用される追加パラメータ。複数のパラメータは、LF (\n) 文字で区切られます。error_handler - (文字列) 前処理ステップが失敗した場合に使用されるアクション タイプ:0 - エラー メッセージは Zabbix サーバーによって設定されます。 1 - 値を破棄します。 2 - カスタム値を設定します。 3 - カスタム エラー メッセージを設定します。 error_handler_params - (string) エラー ハンドラのパラメータ。 |
selectTags | query | tags プロパティでアイテム タグを返します。 |
selectValueMap | query | valuemap プロパティをアイテム値マップと共に返します。 |
filter | object | 指定されたフィルタに正確に一致する結果のみを返します。 配列を受け入れます。キーはプロパティ名で、値は単一の値または照合する値の配列です。 <br >追加のフィルタをサポート: host - アイテムが属するホストの技術名。 |
limitSelects | integer | サブセレクトによって返されるレコードの数を制限します。 次のサブセレクトに適用されます: selectGraphs - 結果は name でソートされます;selectTriggers - 結果はdescription でソートされます . |
sortfield | string/array | 指定されたプロパティで結果を並べ替えます。 使用可能な値は itemid ,name ,key_ ,delay ,history ,trends ,type ,status です。 |
countOutput | boolean | すべてのget メソッドに共通するこれらのパラメーターについてはリファレンス解説ページで詳しく説明されています。 |
editable | boolean | |
excludeSearch | boolean | |
limit | integer | |
output | query | |
preservekeys | boolean | |
search | object | |
searchByAny | boolean | |
searchWildcardsEnabled | boolean | |
sortorder | string/array | |
startSearch | boolean |
(integer/array)
次のいずれかを返します:
countOutput
パラメータが使用されている場合、取得されたオブジェクトの数トリガー固有のホスト ID で使用され、アイテム キーに"system.cpu"という単語が含まれるすべてのアイテムを取得し、結果を名前で並べ替えます。
Request:
{ "jsonrpc": "2.0", "method": "item.get", "params": { "output": "extend", "hostids": "10084", "with_triggers": true, "search": { "key_": "system.cpu" }, "sortfield": "name" }, "auth": "038e1d7b1735c6a5436ee9eae095879e", "id": 1 }
Response:
{ "jsonrpc": "2.0", "result": [ { "itemid": "42269", "type": "18", "snmp_oid": "", "hostid": "10084", "name": "CPU utilization", "key_": "system.cpu.util", "delay": "0", "history": "7d", "trends": "365d", "status": "0", "value_type": "0", "trapper_hosts": "", "units": "%", "logtimefmt": "", "templateid": "42267", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "0", "description": "CPU utilization in %.", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "42264", "timeout": "3s", "url": "", "query_fields": [], "posts": "", "status_codes": "200", "follow_redirects": "1", "post_type": "0", "http_proxy": "", "headers": [], "retrieve_mode": "0", "request_method": "0", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "0", "prevvalue": "0" }, { "itemid": "42259", "type": "0", "snmp_oid": "", "hostid": "10084", "name": "Load average (15m avg)", "key_": "system.cpu.load[all,avg15]", "delay": "1m", "history": "7d", "trends": "365d", "status": "0", "value_type": "0", "trapper_hosts": "", "units": "", "logtimefmt": "", "templateid": "42219", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "1", "description": "", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "0", "timeout": "3s", "url": "", "query_fields": [], "posts": "", "status_codes": "200", "follow_redirects": "1", "post_type": "0", "http_proxy": "", "headers": [], "retrieve_mode": "0", "request_method": "0", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "0", "prevvalue": "0" }, { "itemid": "42249", "type": "0", "snmp_oid": "", "hostid": "10084", "name": "Load average (1m avg)", "key_": "system.cpu.load[all,avg1]", "delay": "1m", "history": "7d", "trends": "365d", "status": "0", "value_type": "0", "trapper_hosts": "", "units": "", "logtimefmt": "", "templateid": "42209", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "1", "description": "", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "0", "timeout": "3s", "url": "", "query_fields": [], "posts": "", "status_codes": "200", "follow_redirects": "1", "post_type": "0", "http_proxy": "", "headers": [], "retrieve_mode": "0", "request_method": "0", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "0", "prevvalue": "0" }, { "itemid": "42257", "type": "0", "snmp_oid": "", "hostid": "10084", "name": "Load average (5m avg)", "key_": "system.cpu.load[all,avg5]", "delay": "1m", "history": "7d", "trends": "365d", "status": "0", "value_type": "0", "trapper_hosts": "", "units": "", "logtimefmt": "", "templateid": "42217", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "1", "description": "", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "0", "timeout": "3s", "url": "", "query_fields": [], "posts": "", "status_codes": "200", "follow_redirects": "1", "post_type": "0", "http_proxy": "", "headers": [], "retrieve_mode": "0", "request_method": "0", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "0", "prevvalue": "0" }, { "itemid": "42260", "type": "0", "snmp_oid": "", "hostid": "10084", "name": "Number of CPUs", "key_": "system.cpu.num", "delay": "1m", "history": "7d", "trends": "365d", "status": "0", "value_type": "3", "trapper_hosts": "", "units": "", "logtimefmt": "", "templateid": "42220", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "1", "description": "", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "0", "timeout": "3s", "url": "", "query_fields": [], "posts": "", "status_codes": "200", "follow_redirects": "1", "post_type": "0", "http_proxy": "", "headers": [], "retrieve_mode": "0", "request_method": "0", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "0", "prevvalue": "0" } ], "id": 1 }
ID が"10116"で、キーに"apache"という単語が含まれるすべての依存アイテムをホストから取得します。
Request:
{ "jsonrpc": "2.0", "method": "item.get", "params": { "output": "extend", "hostids": "10116", "search": { "key_": "apache" }, "filter": { "type": 18 } }, "auth": "038e1d7b1735c6a5436ee9eae095879e", "id": 1 }
Response:
{ "jsonrpc": "2.0", "result": [ { "itemid": "25550", "type": "18", "snmp_oid": "", "hostid": "10116", "name": "Days", "key_": "apache.status.uptime.days", "delay": "0", "history": "90d", "trends": "365d", "status": "0", "value_type": "3", "trapper_hosts": "", "units": "", "logtimefmt": "", "templateid": "0", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "0", "description": "", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "25545", "timeout": "3s", "url": "", "query_fields": [], "posts": "", "status_codes": "200", "follow_redirects": "1", "post_type": "0", "http_proxy": "", "headers": [], "retrieve_mode": "0", "request_method": "0", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "0", "prevvalue": "0" }, { "itemid": "25555", "type": "18", "snmp_oid": "", "hostid": "10116", "name": "Hours", "key_": "apache.status.uptime.hours", "delay": "0", "history": "90d", "trends": "365d", "status": "0", "value_type": "3", "trapper_hosts": "", "units": "", "logtimefmt": "", "templateid": "0", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "0", "description": "", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "25545", "timeout": "3s", "url": "", "query_fields": [], "posts": "", "status_codes": "200", "follow_redirects": "1", "post_type": "0", "http_proxy": "", "headers": [], "retrieve_mode": "0", "request_method": "0", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "0", "prevvalue": "0" } ], "id": 1 }
特定のホストIDの投稿本文タイプが XML の HTTP エージェント アイテムを検索します。
Request:
{ "jsonrpc": "2.0", "method": "item.get", "params": { "hostids": "10255", "filter": { "type": 19, "post_type": 3 } }, "id": 3, "auth": "d678e0b85688ce578ff061bd29a20d3b" }
Response:
{ "jsonrpc": "2.0", "result": [ { "itemid": "28252", "type": "19", "snmp_oid": "", "hostid": "10255", "name": "template item", "key_": "ti", "delay": "30s", "history": "90d", "trends": "365d", "status": "0", "value_type": "3", "trapper_hosts": "", "units": "", "logtimefmt": "", "templateid": "0", "valuemapid": "0", "params": "", "ipmi_sensor": "", "authtype": "0", "username": "", "password": "", "publickey": "", "privatekey": "", "flags": "0", "interfaceid": "0", "description": "", "inventory_link": "0", "evaltype": "0", "jmx_endpoint": "", "master_itemid": "0", "timeout": "3s", "url": "localhost", "query_fields": [ { "mode": "xml" } ], "posts": "<body>\r\n<![CDATA[{$MACRO}<foo></bar>]]>\r\n</body>", "status_codes": "200", "follow_redirects": "0", "post_type": "3", "http_proxy": "", "headers": [], "retrieve_mode": "1", "request_method": "3", "output_format": "0", "ssl_cert_file": "", "ssl_key_file": "", "ssl_key_password": "", "verify_peer": "0", "verify_host": "0", "allow_traps": "0", "uuid": "", "state": "0", "error": "", "parameters": [], "lastclock": "0", "lastns": "0", "lastvalue": "", "prevvalue": "" } ], "id": 3 }
特定のホスト ID のすべてのアイテムとその事前処理ルールを取得します。
Request:
{ "jsonrpc": "2.0", "method": "item.get", "params": { "output": ["itemid", "name", "key_"], "selectPreprocessing": "extend", "hostids": "10254" }, "auth": "038e1d7b1735c6a5436ee9eae095879e", "id": 1 }
Response:
{ "jsonrpc": "2.0", "result": { "itemid": "23865", "name": "HTTP agent example JSON", "key_": "json", "preprocessing": [ { "type": "12", "params": "$.random", "error_handler": "1", "error_handler_params": "" } ] }, "id": 1 }
CItem::get() in ui/include/classes/api/services/CItem.php.