This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
manual:api:reference:host:get [2019/10/07 06:35] 127.0.0.1 external edit |
manual:api:reference:host:get [2021/01/28 15:46] (current) |
||
---|---|---|---|
Line 13: | Line 13: | ||
The method supports the following parameters. | The method supports the following parameters. | ||
- | ^Parameter^Type^Description^ | + | ^Parameter^[[:manual/api/reference_commentary#data_types|Type]]^Description^ |
|groupids|string/array| Return only hosts that belong to the given groups. | | |groupids|string/array| Return only hosts that belong to the given groups. | | ||
|applicationids|string/array| Return only hosts that have the given applications. | | |applicationids|string/array| Return only hosts that have the given applications. | | ||
Line 42: | Line 42: | ||
|with_simple_graph_items|flag|Return only hosts that have items with numeric type of information. | | |with_simple_graph_items|flag|Return only hosts that have items with numeric type of information. | | ||
|with_triggers|flag|Return only hosts that have triggers. \\ \\ Overrides the ''with_monitored_triggers'' parameter. | | |with_triggers|flag|Return only hosts that have triggers. \\ \\ Overrides the ''with_monitored_triggers'' parameter. | | ||
+ | |withProblemsSuppressed|boolean|Return hosts that have suppressed problems. \\ \\ Possible values: \\ ''null'' - (default) all hosts; \\ ''true'' - only hosts with suppressed problems; \\ ''false'' - only hosts with unsuppressed problems. | | ||
|evaltype|integer|Rules for tag searching. \\ \\ Possible values: \\ 0 - (default) And/Or; \\ 2 - Or. | | |evaltype|integer|Rules for tag searching. \\ \\ Possible values: \\ 0 - (default) And/Or; \\ 2 - Or. | | ||
+ | |severities|integer/array|Return hosts that have only problems with given severities. Applies only if problem object is trigger. | | ||
|tags|array/object|Return only hosts with given tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value. \\ Format: ''<nowiki>[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]</nowiki>''.\\ An empty array returns all hosts. \\ \\ Possible operator values: \\ 0 - (default) Contains; \\ 1 - Equals. | | |tags|array/object|Return only hosts with given tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value. \\ Format: ''<nowiki>[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]</nowiki>''.\\ An empty array returns all hosts. \\ \\ Possible operator values: \\ 0 - (default) Contains; \\ 1 - Equals. | | ||
+ | |inheritedTags|boolean|Return hosts that have given ''tags'' also in all of their linked templates. Default: \\ \\ Possible values: \\ ''true'' - linked templates must also have given ''tags''; \\ ''false'' - (default) linked template tags are ignored. | | ||
^ ||| | ^ ||| | ||
|selectApplications|query|Return an ''[[:manual/api/reference/application/object|applications]]'' property with host applications.\\ \\ Supports ''count''. | | |selectApplications|query|Return an ''[[:manual/api/reference/application/object|applications]]'' property with host applications.\\ \\ Supports ''count''. | | ||
Line 59: | Line 62: | ||
|selectScreens|query|Return a ''[[:manual/api/reference/screen/object|screens]]'' property with host screens.\\ \\ Supports ''count''. | | |selectScreens|query|Return a ''[[:manual/api/reference/screen/object|screens]]'' property with host screens.\\ \\ Supports ''count''. | | ||
|selectTags|query|Return a ''[[:manual/api/reference/host/object#host_tag|tags]]'' property with host tags. | | |selectTags|query|Return a ''[[:manual/api/reference/host/object#host_tag|tags]]'' property with host tags. | | ||
+ | |selectInheritedTags|query| Return an ''[[:manual/api/reference/host/object#host_tag|inheritedTags]]'' property with tags that are on all templates which are linked to host. | | ||
|selectTriggers|query|Return a ''[[:manual/api/reference/trigger/object|triggers]]'' property with host triggers.\\ \\ Supports ''count''. | | |selectTriggers|query|Return a ''[[:manual/api/reference/trigger/object|triggers]]'' property with host triggers.\\ \\ Supports ''count''. | | ||
^ ||| | ^ ||| | ||
Line 382: | Line 386: | ||
} | } | ||
] | ] | ||
+ | } | ||
+ | ], | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Retrieve hosts that have these tags not only on host level but also in their linked parent templates. | ||
+ | |||
+ | Request: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "method": "host.get", | ||
+ | "params": { | ||
+ | "output": ["name"], | ||
+ | "tags": [{"tag": "A", "value": "1", "operator": "0"}], | ||
+ | "inheritedTags": true | ||
+ | }, | ||
+ | "auth": "038e1d7b1735c6a5436ee9eae095879e", | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "result": [ | ||
+ | { | ||
+ | "hostid": "10623", | ||
+ | "name": "PC room 1" | ||
+ | }, | ||
+ | { | ||
+ | "hostid": "10601", | ||
+ | "name": "Office" | ||
+ | } | ||
+ | ], | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | === Searching host with tags and template tags === | ||
+ | |||
+ | Retrieve a host with tags and all tags that are linked to parent templates. | ||
+ | |||
+ | Request: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "method": "host.get", | ||
+ | "params": { | ||
+ | "output": ["name"], | ||
+ | "hostids": 10502, | ||
+ | "selectTags": ["tag", "value"], | ||
+ | "selectInheritedTags": ["tag", "value"] | ||
+ | }, | ||
+ | "auth": "038e1d7b1735c6a5436ee9eae095879e", | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "result": [ | ||
+ | { | ||
+ | "hostid": "10502", | ||
+ | "name": "Desktop", | ||
+ | "tags": [ | ||
+ | { | ||
+ | "tag": "A", | ||
+ | "value": "1" | ||
+ | } | ||
+ | ], | ||
+ | "inheritedTags": [ | ||
+ | { | ||
+ | "tag": "B", | ||
+ | "value": "2" | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ], | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | === Searching hosts by problem severity === | ||
+ | |||
+ | Retrieve hosts that have "Disaster" problems. | ||
+ | |||
+ | Request: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "method": "host.get", | ||
+ | "params": { | ||
+ | "output": ["name"], | ||
+ | "severities": 5 | ||
+ | }, | ||
+ | "auth": "038e1d7b1735c6a5436ee9eae095879e", | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "result": [ | ||
+ | { | ||
+ | "hostid": "10160", | ||
+ | "name": "Zabbix server" | ||
+ | } | ||
+ | ], | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Retrieve hosts that have "Average" and "High" problems. | ||
+ | |||
+ | Request: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "method": "host.get", | ||
+ | "params": { | ||
+ | "output": ["name"], | ||
+ | "severities": [3, 4] | ||
+ | }, | ||
+ | "auth": "038e1d7b1735c6a5436ee9eae095879e", | ||
+ | "id": 1 | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Response: | ||
+ | <code java> | ||
+ | { | ||
+ | "jsonrpc": "2.0", | ||
+ | "result": [ | ||
+ | { | ||
+ | "hostid": "20170", | ||
+ | "name": "Database" | ||
+ | }, | ||
+ | { | ||
+ | "hostid": "20183", | ||
+ | "name": "workstation" | ||
} | } | ||
], | ], | ||
Line 397: | Line 548: | ||
==== Source ==== | ==== Source ==== | ||
- | CHost::get() in //frontends/php/include/classes/api/services/CHost.php//. | + | CHost::get() in //ui/include/classes/api/services/CHost.php//. |