Zabbix Documentation 4.2

3.04.05.0 (current)| In development:5.2 (devel)| Unsupported:1.82.02.22.43.23.44.24.4Guidelines

User Tools

Site Tools


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 [2015/06/03 08:23]
richlv fix typos
manual:api:reference:host:get [2019/07/10 08:59] (current)
martins-v formatting change
Line 40: Line 40:
 |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.| |withInventory|flag|Return only hosts that have inventory data.|
 +|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. |
 ^  ||| ^  |||
-|selectGroups|query|Return ​the host groups that the host belongs to in the ''​groups''​ property. | +|selectGroups|query|Return ​a ''​[[:​manual/​api/​reference/​hostgroup/​object|groups]]''​ property with host groups ​data that the host belongs to.  | 
-|selectApplications|query|Return ​the applications from the host in the ''​applications''​ property. \\ \\ Supports ''​count''​. | +|selectTags|query|Return a ''​[[:​manual/​api/​reference/​host/​object#​host_tag|tags]]''​ property ​with host tags. | 
-|selectDiscoveries|query|Return ​the low level discoveries from the host in the ''​discoveries''​ property. \\ \\ Supports ''​count''​. | +|selectApplications|query|Return ​an ''​[[:​manual/​api/​reference/​application/​object|applications]]''​ property ​with host applications.\\ \\ Supports ''​count''​. | 
-|selectDiscoveryRule | query | Return the LLD rule that created the host in the ''​discoveryRule''​ property. | +|selectDiscoveries|query|Return ​''​[[:​manual/​api/​reference/​discoveryrule/​object|discoveries]]''​ property ​with host low-level discovery rules.\\ \\ Supports ''​count''​. | 
-|selectGraphs|query|Return ​the graphs from the host in the ''​graphs''​ property. \\ \\ Supports ''​count''​. | +|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) 
-|selectHostDiscovery | query | Return ​the host discovery object in the ''​hostDiscovery''​ property. \\ \\ 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. | +|selectGraphs|query|Return ​''​[[:​manual/​api/​reference/​graph/​object|graphs]]''​ property ​with host graphs.\\ \\ Supports ''​count''​. | 
-|selectHttpTests|query|Return ​the web scenarios from the host in the ''​httpTests''​ property. \\ \\ Supports ''​count''​. | +|selectHostDiscovery |query|Return ​''​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. | 
-|selectInterfaces|query|Return ​the host interfaces in the ''​interfaces''​ property. \\ \\ Supports ''​count''​. | +|selectHttpTests|query|Return ​an ''​[[:​manual/​api/​reference/​httptest/​object|httpTests]]''​ property ​with host web scenarios.\\ \\ Supports ''​count''​. | 
-|selectInventory|query|Return ​the host inventory from the host in the ''​inventory''​ property. | +|selectInterfaces|query|Return ​an ''​[[:​manual/​api/​reference/​hostinterface/​object|interfaces]]''​ property ​with host interfaces.\\ \\ Supports ''​count''​. | 
-|selectItems|query|Return ​the items from the host in the ''​items''​ property. \\ \\ Supports ''​count''​. | +|selectInventory|query|Return ​an ''​[[:​manual/​api/​reference/​host/​object#​host_inventory|inventory]]''​ property ​with host inventory data 
-|selectMacros|query|Return ​the macros from the host in the ''​macros''​ property. | +|selectItems|query|Return ​an ''​[[:​manual/​api/​reference/​item/​object|items]]''​ property ​with host items.\\ \\ Supports ''​count''​. | 
-|selectParentTemplates|query|Return ​the templates that the host is linked to in the ''​parentTemplates''​ property. \\ \\ Supports ''​count''​. | +|selectMacros|query|Return ​''​[[:​manual/​api/​reference/​usermacro/​object|macros]]''​ property ​with host macros 
-|selectScreens|query|Return ​the screens from the host in the ''​screens''​ property. \\ \\ Supports ''​count''​. | +|selectParentTemplates|query|Return ​a ''​[[:​manual/​api/​reference/​template/​object|parentTemplates]]''​ property with templates that the host is linked to.\\ \\ Supports ''​count''​. | 
-|selectTriggers|query|Return ​the triggers from the host in the ''​triggers''​ property. \\ \\ Supports ''​count''​. |+|selectScreens|query|Return ​''​[[:​manual/​api/​reference/​screen/​object|screens]]''​ property ​with host screens.\\ \\ Supports ''​count''​. | 
 +|selectTriggers|query|Return ​''​[[:​manual/​api/​reference/​trigger/​object|triggers]]''​ property ​with host triggers.\\ \\ Supports ''​count''​. |
 ^  ||| ^  |||
 |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. |
Line 61: Line 64:
 |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''​. |
 |sortfield|string/​array| Sort the result by the given properties. \\ \\ Possible values are: ''​hostid'',​ ''​host'',​ ''​name'',​ ''​status''​. ​ | |sortfield|string/​array| Sort the result by the given properties. \\ \\ Possible values are: ''​hostid'',​ ''​host'',​ ''​name'',​ ''​status''​. ​ |
-|countOutput|flag|These parameters being common for all ''​get''​ methods are described in detail in the [[manual:​api:​reference_commentary#​common_get_method_parameters|reference commentary]]. ​ |+|countOutput|boolean|These parameters being common for all ''​get''​ methods are described in detail in the [[manual:​api:​reference_commentary#​common_get_method_parameters|reference commentary]]. ​ |
 | editable |boolean|:::​| | editable |boolean|:::​|
-| excludeSearch |flag|:::|+| excludeSearch |boolean|:::|
 | limit |integer|:::​| | limit |integer|:::​|
 | output |query|:::| | output |query|:::|
-| preservekeys |flag|:::|+| preservekeys |boolean|:::|
 | searchByAny |boolean|:::​| | searchByAny |boolean|:::​|
 | searchWildcardsEnabled |boolean|:::​| | searchWildcardsEnabled |boolean|:::​|
 | sortorder | string/​array | ::: | | sortorder | string/​array | ::: |
-| startSearch |flag|:::|+| startSearch |boolean|:::|
 ==== Return values ==== ==== Return values ====
  
Line 84: Line 87:
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
     "​method":​ "​host.get",​     "​method":​ "​host.get",​
     "​params":​ {     "​params":​ {
-        "​output":​ "​extend",​ 
         "​filter":​ {         "​filter":​ {
             "​host":​ [             "​host":​ [
Line 103: Line 105:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 139: Line 141:
             "​jmx_error":​ "",​             "​jmx_error":​ "",​
             "​name":​ "​Zabbix server",​             "​name":​ "​Zabbix server",​
-            "​description":​ "The Zabbix monitoring server."​+            "​description":​ "The Zabbix monitoring server.", 
 +            "​tls_connect":​ "​1",​ 
 +            "​tls_accept":​ "​1",​ 
 +            "​tls_issuer":​ "",​ 
 +            "​tls_subject":​ "",​ 
 +            "​tls_psk_identity":​ "",​ 
 +            "​tls_psk":​ ""
         },         },
         {         {
Line 173: Line 181:
             "​jmx_error":​ "",​             "​jmx_error":​ "",​
             "​name":​ "Linux server",​             "​name":​ "Linux server",​
-            "​description":​ ""​+            "​description": "",​ 
 +            "​tls_connect":​ "​1",​ 
 +            "​tls_accept":​ "​1",​ 
 +            "​tls_issuer":​ "",​ 
 +            "​tls_subject":​ "",​ 
 +            "​tls_psk_identity":​ "",​ 
 +            "​tls_psk": ""​
         }         }
     ],     ],
Line 184: Line 198:
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 203: Line 217:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 234: Line 248:
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 252: Line 266:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 279: Line 293:
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 300: Line 314:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 317: Line 331:
                 "​os":​ "Linux Mint"                 "​os":​ "Linux Mint"
             }             }
 +        }
 +    ],
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +=== Searching by host tags ===
 +
 +Retrieve hosts that have tag "Host name" equal to "Linux server"​.
 +
 +Request:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​method":​ "​host.get",​
 +    "​params":​ {
 +        "​output":​ ["​hostid"​],​
 +        "​selectTags":​ "​extend",​
 +        "​evaltype":​ 0,
 +        "​tags":​ [
 +            {
 +                "​tag":​ "Host name",
 +                "​value":​ "Linux server",​
 +                "​operator":​ 1
 +            }
 +        ]
 +    },
 +    "​auth":​ "​7f9e00124c75e8f25facd5c093f3e9a0",​
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ [
 +        {
 +            "​hostid":​ "​10085",​
 +            "​tags":​ [
 +                {
 +                    "​tag":​ "Host name",
 +                    "​value":​ "Linux server"​
 +                },
 +                {
 +                    "​tag":​ "​OS",​
 +                    "​value":​ "RHEL 7"
 +                }
 +            ]
         }         }
     ],     ],
Line 325: Line 388:
 ==== See also ==== ==== See also ====
  
-  * [[getobjects|host.getobjects]] 
   * [[manual:​api:​reference:​hostgroup:​object#​host_group|Host group]]   * [[manual:​api:​reference:​hostgroup:​object#​host_group|Host group]]
   * [[manual:​api:​reference:​template:​object#​template|Template]]   * [[manual:​api:​reference:​template:​object#​template|Template]]
   * [[manual:​api:​reference:​usermacro:​object#​hosttemplate_level_macro|User macro]]   * [[manual:​api:​reference:​usermacro:​object#​hosttemplate_level_macro|User macro]]
   * [[manual:​api:​reference:​hostinterface:​object#​host_interface|Host interface]]   * [[manual:​api:​reference:​hostinterface:​object#​host_interface|Host interface]]
 +
 ==== Source ==== ==== Source ====
  
-CHost::​get() in //​frontends/​php/​api/​classes/​CHost.php//​.+CHost::​get() in //​frontends/​php/​include/classes/​api/​services/​CHost.php//​.