Zabbix Documentation 3.2

3.04.04.45.0 (current)| In development:5.2 (devel)| Unsupported:1.82.02.22.43.23.44.2Guidelines

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

Next revision
Previous revision
manual:api:reference:host:get [2014/02/17 14:02]
127.0.0.1 external edit
manual:api:reference:host:get [2019/01/28 14:50] (current)
sasha <code js> => <code java>
Line 42: Line 42:
 ^  ||| ^  |||
 |selectGroups|query|Return the host groups that the host belongs to in the ''​groups''​ property. | |selectGroups|query|Return the host groups that the host belongs to in the ''​groups''​ property. |
-|selectApplications|query|Return the applications from the host in the ''​applications''​ property. \\ \\ Support ​''​count''​. |+|selectApplications|query|Return the applications from the host in the ''​applications''​ property. \\ \\ Supports ​''​count''​. |
 |selectDiscoveries|query|Return the low level discoveries from the host in the ''​discoveries''​ property. \\ \\ Supports ''​count''​. | |selectDiscoveries|query|Return the low level discoveries from the host in the ''​discoveries''​ property. \\ \\ Supports ''​count''​. |
-| selectDiscoveryRule | query | Return the LLD rule that created the host in the ''​discoveryRule''​ property. |+|selectDiscoveryRule | query | Return the LLD rule that created the host in the ''​discoveryRule''​ property. |
 |selectGraphs|query|Return the graphs from the host in the ''​graphs''​ property. \\ \\ Supports ''​count''​. | |selectGraphs|query|Return the graphs from the host in the ''​graphs''​ property. \\ \\ Supports ''​count''​. |
-| 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. |+|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. |
 |selectHttpTests|query|Return the web scenarios from the host in the ''​httpTests''​ property. \\ \\ Supports ''​count''​. | |selectHttpTests|query|Return the web scenarios from the host in the ''​httpTests''​ property. \\ \\ Supports ''​count''​. |
 |selectInterfaces|query|Return the host interfaces in the ''​interfaces''​ property. \\ \\ Supports ''​count''​. | |selectInterfaces|query|Return the host interfaces in the ''​interfaces''​ property. \\ \\ Supports ''​count''​. |
-|selectInventory|boolean/​array|Return the host inventory from the host in the ''​inventory''​ property. \\ \\ Possible values are ''​true''​ to return all of the data, or an array of property names to return only specific properties.|+|selectInventory|query|Return the host inventory from the host in the ''​inventory''​ property. |
 |selectItems|query|Return the items from the host in the ''​items''​ property. \\ \\ Supports ''​count''​. | |selectItems|query|Return the items from the host in the ''​items''​ property. \\ \\ Supports ''​count''​. |
 |selectMacros|query|Return the macros from the host in the ''​macros''​ property. | |selectMacros|query|Return the macros from the host in the ''​macros''​ property. |
Line 59: Line 59:
 | 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'';​ \\ ''​selectApplications''​ - sorted by ''​name'';​ \\ ''​selectScreens''​ - 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''​. |
 |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 [[2.4:manual:​api:​reference_commentary#​common_get_method_parameters|reference commentary]]. ​ |+|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]]. ​ |
 | editable |boolean|:::​| | editable |boolean|:::​|
 | excludeSearch |flag|:::| | excludeSearch |flag|:::|
 | limit |integer|:::​| | limit |integer|:::​|
-| nodeids |string/​array|:::​| 
 | output |query|:::| | output |query|:::|
 | preservekeys |flag|:::| | preservekeys |flag|:::|
Line 84: Line 84:
  
 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 102:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 138: Line 137:
             "​jmx_errors_from":​ "​0",​             "​jmx_errors_from":​ "​0",​
             "​jmx_error":​ "",​             "​jmx_error":​ "",​
-            "​name":​ "​Zabbix server"​+            "​name":​ "​Zabbix server", 
 +            "​description":​ "The Zabbix monitoring server.",​ 
 +            "​tls_connect":​ "​1",​ 
 +            "​tls_accept":​ "​1",​ 
 +            "​tls_issuer":​ "",​ 
 +            "​tls_subject":​ "",​ 
 +            "​tls_psk_identity":​ "",​ 
 +            "​tls_psk":​ ""
         },         },
         {         {
Line 171: Line 177:
             "​jmx_errors_from":​ "​0",​             "​jmx_errors_from":​ "​0",​
             "​jmx_error":​ "",​             "​jmx_error":​ "",​
-            "​name":​ "Linux server"​+            "​name":​ "Linux server", 
 +            "​description":​ "",​ 
 +            "​tls_connect":​ "​1",​ 
 +            "​tls_accept":​ "​1",​ 
 +            "​tls_issuer":​ "",​ 
 +            "​tls_subject":​ "",​ 
 +            "​tls_psk_identity":​ "",​ 
 +            "​tls_psk":​ ""
         }         }
     ],     ],
Line 177: Line 190:
 } }
 </​code>​ </​code>​
- 
 === Retrieving host groups === === Retrieving host groups ===
  
Line 183: Line 195:
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 202: Line 214:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 233: Line 245:
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 251: Line 263:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 272: Line 284:
 } }
 </​code>​ </​code>​
 +
 +=== Searching by host inventory data ===
 +
 +Retrieve hosts that contain "​Linux"​ in the host inventory "​OS"​ field.
 +
 +Request:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​method":​ "​host.get",​
 +    "​params":​ {
 +        "​output":​ [
 +            "​host"​
 +        ],
 +        "​selectInventory":​ [
 +            "​os"​
 +        ],
 +        "​searchInventory":​ {
 +            "​os":​ "​Linux"​
 +        }
 +    },
 +    "​id":​ 2,
 +    "​auth":​ "​7f9e00124c75e8f25facd5c093f3e9a0"​
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ [
 +        {
 +            "​hostid":​ "​10084",​
 +            "​host":​ "​Zabbix server",​
 +            "​inventory":​ {
 +                "​os":​ "Linux Ubuntu"​
 +            }
 +        },
 +        {
 +            "​hostid":​ "​10107",​
 +            "​host":​ "Linux server",​
 +            "​inventory":​ {
 +                "​os":​ "Linux Mint"
 +            }
 +        }
 +    ],
 +    "​id":​ 1
 +}
 +</​code>​
 +
 ==== See also ==== ==== See also ====
  
-  * [[2.4:​manual:​api:​reference:​host:​getobjects|host.getobjects]] +  * [[manual:​api:​reference:​hostgroup:​object#​host_group|Host group]] 
-  * [[2.4:manual:​api:​reference:​hostgroup:​object#​host_group|Host group]] +  * [[manual:​api:​reference:​template:​object#​template|Template]] 
-  * [[2.4:manual:​api:​reference:​template:​object#​template|Template]] +  * [[manual:​api:​reference:​usermacro:​object#​hosttemplate_level_macro|User macro]] 
-  * [[2.4:manual:​api:​reference:​usermacro:​object#​hosttemplate_level_macro|User macro]] +  * [[manual:​api:​reference:​hostinterface:​object#​host_interface|Host interface]] 
-  * [[2.4: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//​.