manual:api:reference:host:get

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:api:reference:host:get [2019/02/05 10:54]
martins-v adding useful links to referenced object pages
manual:api:reference:host:get [2021/05/13 14:37] (current)
miks.kronkalns (ZBXNEXT-2976) Removed support for request parameters ‘’selectApplications’’, ‘’with_applications’’ and ‘’applicationids’’.
Line 6: Line 6:
  
 The method allows to retrieve hosts according to the given parameters. The method allows to retrieve hosts according to the given parameters.
 +
 +<​note>​This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See [[:​manual/​web_interface/​frontend_sections/​administration/​user_roles|User roles]] for more information.</​note>​
  
 ==== Parameters ==== ==== Parameters ====
Line 13: Line 15:
 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. | 
 |dserviceids|string/​array| Return only hosts that are related to the given discovered services.| |dserviceids|string/​array| Return only hosts that are related to the given discovered services.|
 |graphids|string/​array| Return only hosts that have the given graphs. | |graphids|string/​array| Return only hosts that have the given graphs. |
Line 31: Line 32:
 ^  ||| ^  |||
 |with_items|flag|Return only hosts that have items. \\ \\ Overrides the ''​with_monitored_items''​ and ''​with_simple_graph_items''​ parameters. | |with_items|flag|Return only hosts that have items. \\ \\ Overrides the ''​with_monitored_items''​ and ''​with_simple_graph_items''​ parameters. |
-|with_applications|flag|Return only hosts that have applications. |+|with_item_prototypes|flag|Return only hosts that have item prototypes. \\ \\ Overrides the ''​with_simple_graph_item_prototypes''​ parameter. | 
 +|with_simple_graph_item_prototypes|flag|Return only hosts that have item prototypes, which are enabled for creation and have numeric type of information. |
 |with_graphs|flag|Return only hosts that have graphs. | |with_graphs|flag|Return only hosts that have graphs. |
 +|with_graph_prototypes|flag|Return only hosts that have graph prototypes. |
 |with_httptests|flag|Return only hosts that have web checks. \\ \\ Overrides the ''​with_monitored_httptests''​ parameter. | |with_httptests|flag|Return only hosts that have web checks. \\ \\ Overrides the ''​with_monitored_httptests''​ parameter. |
 |with_monitored_httptests|flag|Return only hosts that have enabled web checks. | |with_monitored_httptests|flag|Return only hosts that have enabled web checks. |
Line 39: 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. |
-|withInventory|flag|Return ​only hosts that have inventory data.|+|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. |
-|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. |+|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; \\ 2 - Not like; \\ 3 - Not equal \\ 4 - Exists; \\ 5 - Not exists. | 
 +|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. |
 ^  ||| ^  |||
-|selectGroups|query|Return a ''​groups''​ property with data of the [[:​manual/​api/​reference/​hostgroup/object|host groups]] that the host belongs to.  | +|selectDiscoveries|query|Return a ''​[[:​manual/​api/​reference/​discoveryrule/object|discoveries]]''​ property with host low-level discovery rules.\\ \\ Supports ''​count''​. | 
-|selectTags|query|Return a ''​tags''​ property with host tags. | +|selectDiscoveryRule ​|query|Return a ''​[[:​manual/​api/​reference/​discoveryrule/​object|discoveryRule]]''​ property with the low-level discovery rule that created the host (from host prototype in VMware monitoring). ​ | 
-|selectApplications|query|Return an ''​applications''​ property with [[:​manual/​api/​reference/​application/​object|application]] data of the host.\\ \\ Supports ''​count''​. | +|selectGraphs|query|Return a ''​[[:​manual/​api/​reference/​graph/​object|graphs]]''​ property with host graphs.\\ \\ Supports ''​count''​. ​
-|selectDiscoveries|query|Return a ''​discoveries''​ property with [[:​manual/​api/​reference/​discoveryrule/​object|low-level discovery]] data of the host.\\ \\ Supports ''​count''​. | +|selectGroups|query|Return a ''​[[:​manual/​api/​reference/​hostgroup/​object|groups]]''​ property with host groups data that the host belongs to.  ​|
-|selectDiscoveryRule |query|Return a ''​discoveryRule''​ property with data of the [[:​manual/​api/​reference/​discoveryrule/​object|low-level discovery]] rule that created the host (from host prototype in VMware monitoring). ​ | +
-|selectGraphs|query|Return a ''​graphs''​ property with [[:​manual/​api/​reference/​graph/​object|graph]] data of the host.\\ \\ Supports ''​count''​. |+
 |selectHostDiscovery |query|Return a ''​hostDiscovery''​ property with host discovery object data.\\ \\ The host discovery object links a discovered host to a host prototype or a host prototypes to an LLD rule and has the following properties: \\ ''​host''​ - //​(string)//​ host of the host prototype; \\  ''​hostid''​ - //​(string)//​ ID of the discovered host or host prototype; \\ ''​parent_hostid''​ - //​(string)//​ ID of the host prototype from which the host has been created; \\ ''​parent_itemid''​ - //​(string)//​ ID of the LLD rule that created the discovered host; \\ ''​lastcheck''​ - //​(timestamp)//​ time when the host was last discovered; \\ ''​ts_delete''​ - //​(timestamp)//​ time when a host that is no longer discovered will be deleted. | |selectHostDiscovery |query|Return a ''​hostDiscovery''​ property with host discovery object data.\\ \\ The host discovery object links a discovered host to a host prototype or a host prototypes to an LLD rule and has the following properties: \\ ''​host''​ - //​(string)//​ host of the host prototype; \\  ''​hostid''​ - //​(string)//​ ID of the discovered host or host prototype; \\ ''​parent_hostid''​ - //​(string)//​ ID of the host prototype from which the host has been created; \\ ''​parent_itemid''​ - //​(string)//​ ID of the LLD rule that created the discovered host; \\ ''​lastcheck''​ - //​(timestamp)//​ time when the host was last discovered; \\ ''​ts_delete''​ - //​(timestamp)//​ time when a host that is no longer discovered will be deleted. |
-|selectHttpTests|query|Return an ''​httpTests''​ property with [[:​manual/​api/​reference/​httptest/​object|web scenario]] data of the host.\\ \\ Supports ''​count''​. | +|selectHttpTests|query|Return an ''​[[:​manual/​api/​reference/​httptest/​object|httpTests]]''​ property with host web scenarios.\\ \\ Supports ''​count''​. | 
-|selectInterfaces|query|Return an ''​interfaces''​ property with [[:​manual/​api/​reference/​hostinterface/​object|interface]] data of the host.\\ \\ Supports ''​count''​. | +|selectInterfaces|query|Return an ''​[[:​manual/​api/​reference/​hostinterface/​object|interfaces]]''​ property with host interfaces.\\ \\ Supports ''​count''​. | 
-|selectInventory|query|Return an ''​inventory''​ property with [[:​manual/​api/​reference/​host/​object#​host_inventory|inventory]] ​data of the host.  | +|selectInventory|query|Return an ''​[[:​manual/​api/​reference/​host/​object#​host_inventory|inventory]]''​ property with host inventory data.  | 
-|selectItems|query|Return an ''​items''​ property with [[:​manual/​api/​reference/​item/​object|item]] data of the host.\\ \\ Supports ''​count''​. | +|selectItems|query|Return an ''​[[:​manual/​api/​reference/​item/​object|items]]''​ property with host items.\\ \\ Supports ''​count''​. | 
-|selectMacros|query|Return a ''​macros''​ property with [[:​manual/​api/​reference/​usermacro/​object|macro]] data of the host.  | +|selectMacros|query|Return a ''​[[:​manual/​api/​reference/​usermacro/​object|macros]]''​ property with host macros.  | 
-|selectParentTemplates|query|Return a ''​parentTemplates''​ property with data of the [[:​manual/​api/​reference/​template/​object|templates]] that the host is linked to.\\ \\ Supports ''​count''​. | +|selectParentTemplates|query|Return a ''​[[:​manual/​api/​reference/​template/​object|parentTemplates]]''​ property with templates ​that the host is linked to.\\ \\ Supports ''​count''​. | 
-|selectScreens|query|Return a ''​screens''​ property with [[:​manual/​api/​reference/​screen/object|screen]] data of the host.\\ \\ Supports ''​count''​. | +|selectDashboards ​| query | Return a ''​[[:​manual/​api/​reference/​templatedashboard/object|dashboards]]''​ property. \\ \\ Supports ''​count''​. | 
-|selectTriggers|query|Return a ''​triggers''​ property with [[:​manual/​api/​reference/​trigger/​object|trigger]] ​data of the host.\\ \\ Supports ''​count''​. |+|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''​. | 
 +|selectValueMaps|query|Return a ''​[[:​manual/​api/​reference/​valuemap/​object|valuemaps]]''​ property with host value maps. |
 ^  ||| ^  |||
 |filter ​ | object |Return only those results that exactly match the given filter.\\ \\ Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against. \\ \\ Allows filtering by interface properties. | |filter ​ | object |Return only those results that exactly match the given filter.\\ \\ Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against. \\ \\ Allows filtering by interface properties. |
-| limitSelects | integer | Limits the number of records returned by subselects. \\  \\ Applies to the following subselects: \\ ''​selectParentTemplates''​ - results will be sorted by ''​host'';​ \\ ''​selectInterfaces'';​ \\ ''​selectItems''​ - sorted by ''​name'';​ \\ ''​selectDiscoveries''​ - sorted by ''​name'';​ \\ ''​selectTriggers''​ - sorted by ''​description'';​ \\ ''​selectGraphs''​ - sorted by ''​name'';​ \\ ''​selectApplications''​ - sorted by ''​name'';​ \\ ''​selectScreens''​ - sorted by ''​name''​. |+| limitSelects | integer | Limits the number of records returned by subselects. \\  \\ Applies to the following subselects: \\ ''​selectParentTemplates''​ - results will be sorted by ''​host'';​ \\ ''​selectInterfaces'';​ \\ ''​selectItems''​ - sorted by ''​name'';​ \\ ''​selectDiscoveries''​ - sorted by ''​name'';​ \\ ''​selectTriggers''​ - sorted by ''​description'';​ \\ ''​selectGraphs''​ - sorted by ''​name'';​ \\ ''​selectDashboards''​ - sorted by ''​name''​. |
 |search ​ | object |Return results that match the given wildcard search.\\ \\ Accepts an array, where the keys are property names, and the values are strings to search for. If no additional options are given, this will perform a ''​LIKE "​%…%"''​ search.\\ \\ Allows searching by interface properties. Works only with text fields. | |search ​ | object |Return results that match the given wildcard search.\\ \\ Accepts an array, where the keys are property names, and the values are strings to search for. If no additional options are given, this will perform a ''​LIKE "​%…%"''​ search.\\ \\ Allows searching by interface properties. Works only with text fields. |
 |searchInventory | object | Return only hosts that have inventory data matching the given wildcard search. \\ \\ This parameter is affected by the same additional parameters as ''​search''​. | |searchInventory | object | Return only hosts that have inventory data matching the given wildcard search. \\ \\ This parameter is affected by the same additional parameters as ''​search''​. |
Line 115: Line 121:
             "​host":​ "​Zabbix server",​             "​host":​ "​Zabbix server",​
             "​status":​ "​0",​             "​status":​ "​0",​
-            "​disable_until":​ "​0",​ 
-            "​error":​ "",​ 
-            "​available":​ "​0",​ 
-            "​errors_from":​ "​0",​ 
             "​lastaccess":​ "​0",​             "​lastaccess":​ "​0",​
             "​ipmi_authtype":​ "​-1",​             "​ipmi_authtype":​ "​-1",​
Line 125: Line 127:
             "​ipmi_password":​ "",​             "​ipmi_password":​ "",​
             "​ipmi_disable_until":​ "​0",​             "​ipmi_disable_until":​ "​0",​
-            "​ipmi_available":​ "​0",​ 
             "​snmp_disable_until":​ "​0",​             "​snmp_disable_until":​ "​0",​
-            "​snmp_available":​ "​0",​ 
             "​maintenanceid":​ "​0",​             "​maintenanceid":​ "​0",​
             "​maintenance_status":​ "​0",​             "​maintenance_status":​ "​0",​
             "​maintenance_type":​ "​0",​             "​maintenance_type":​ "​0",​
             "​maintenance_from":​ "​0",​             "​maintenance_from":​ "​0",​
-            "​ipmi_errors_from":​ "​0",​ 
-            "​snmp_errors_from":​ "​0",​ 
-            "​ipmi_error":​ "",​ 
-            "​snmp_error":​ "",​ 
-            "​jmx_disable_until":​ "​0",​ 
-            "​jmx_available":​ "​0",​ 
-            "​jmx_errors_from":​ "​0",​ 
-            "​jmx_error":​ "",​ 
             "​name":​ "​Zabbix server",​             "​name":​ "​Zabbix server",​
             "​description":​ "The Zabbix monitoring server.",​             "​description":​ "The Zabbix monitoring server.",​
Line 145: Line 137:
             "​tls_accept":​ "​1",​             "​tls_accept":​ "​1",​
             "​tls_issuer":​ "",​             "​tls_issuer":​ "",​
-            "​tls_subject": "",​ +            "​tls_subject":​ ""​
-            "​tls_psk_identity":​ "",​ +
-            "​tls_psk": ""​+
         },         },
         {         {
Line 155: Line 145:
             "​host":​ "Linux server",​             "​host":​ "Linux server",​
             "​status":​ "​0",​             "​status":​ "​0",​
-            "​disable_until":​ "​0",​ 
-            "​error":​ "",​ 
-            "​available":​ "​0",​ 
-            "​errors_from":​ "​0",​ 
             "​lastaccess":​ "​0",​             "​lastaccess":​ "​0",​
             "​ipmi_authtype":​ "​-1",​             "​ipmi_authtype":​ "​-1",​
Line 165: Line 151:
             "​ipmi_password":​ "",​             "​ipmi_password":​ "",​
             "​ipmi_disable_until":​ "​0",​             "​ipmi_disable_until":​ "​0",​
-            "​ipmi_available":​ "​0",​ 
             "​snmp_disable_until":​ "​0",​             "​snmp_disable_until":​ "​0",​
-            "​snmp_available":​ "​0",​ 
             "​maintenanceid":​ "​0",​             "​maintenanceid":​ "​0",​
             "​maintenance_status":​ "​0",​             "​maintenance_status":​ "​0",​
             "​maintenance_type":​ "​0",​             "​maintenance_type":​ "​0",​
             "​maintenance_from":​ "​0",​             "​maintenance_from":​ "​0",​
-            "​ipmi_errors_from":​ "​0",​ 
-            "​snmp_errors_from":​ "​0",​ 
-            "​ipmi_error":​ "",​ 
-            "​snmp_error":​ "",​ 
-            "​jmx_disable_until":​ "​0",​ 
-            "​jmx_available":​ "​0",​ 
-            "​jmx_errors_from":​ "​0",​ 
-            "​jmx_error":​ "",​ 
             "​name":​ "Linux server",​             "​name":​ "Linux server",​
             "​description":​ "",​             "​description":​ "",​
Line 185: Line 161:
             "​tls_accept":​ "​1",​             "​tls_accept":​ "​1",​
             "​tls_issuer":​ "",​             "​tls_issuer":​ "",​
-            "​tls_subject": "",​ +            "​tls_subject":​ ""​
-            "​tls_psk_identity":​ "",​ +
-            "​tls_psk": ""​+
         }         }
     ],     ],
Line 274: Line 248:
             "​parentTemplates":​ [             "​parentTemplates":​ [
                 {                 {
-                    "​name":​ "Template OS Linux",​+                    "​name":​ "​Linux",​
                     "​templateid":​ "​10001"​                     "​templateid":​ "​10001"​
                 },                 },
                 {                 {
-                    "​name":​ "Template App Zabbix Server",​+                    "​name":​ "​Zabbix Server",​
                     "​templateid":​ "​10047"​                     "​templateid":​ "​10047"​
                 }                 }
Line 380: Line 354:
                 }                 }
             ]             ]
 +        }
 +    ],
 +    "​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 395: Line 516:
 ==== Source ==== ==== Source ====
  
-CHost::​get() in //frontends/​php/​include/​classes/​api/​services/​CHost.php//​.+CHost::​get() in //ui/​include/​classes/​api/​services/​CHost.php//​.