api: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
api:host:get [2014/09/30 12:54]
api:host:get [2019/01/28 14:45] (current)
sasha <code js> => <code java>
Line 1: Line 1:
 +===== get() =====
 +Available since version: **1.8**\\
 +This function allows you to retrieve host details based on filtering options.
 +All parameters are optional. If parameter is set in query this option counted as ON, except if parameter is equal to NULL.
  
 +====Parameters====
 +^Parameter^Type^Description^Details^
 +|**nodeids**|//​array//​|Node IDs | |
 +|**groupids**|//​array//​|HostGroup IDs | |
 +|**hostids**|//​array//​|Host IDs | |
 +|**templateids**|//​array//​|Template IDs | |
 +|**itemids**|//​array//​|Item IDs | |
 +|**triggerids**|//​array//​|Trigger IDs | |
 +|**graphids**|//​array//​|Graph IDs | |
 +|**proxyids**|//​array//​|Proxy IDs | |
 +|**maintenanceids**|//​array//​|Maintenance IDs | |
 +|**dhostids**|//​array//​|Discovered host IDs | |
 +|**dserviceids**|//​array//​|Discovered services IDs | |
 +|**monitored_hosts**|//​integer//​|return only monitored Hosts| |
 +|**templated_hosts**|//​integer//​|include templates in result | |
 +|**proxy_hosts**|//​integer//​|return only Proxies | |
 +|**with_items**|//​integer//​|only with items | |
 +|**with_monitored_items**|//​integer//​|only with monitored items | |
 +|**with_historical_items**|//​integer//​|only with historical items | |
 +|**with_triggers**|//​integer//​|only with triggers | |
 +|**with_monitored_triggers**|//​integer//​|only with monitored triggers | |
 +|**with_httptests**|//​integer//​|only with http tests | |
 +|**with_monitored_httptests**|//​integer//​|only with monitored http tests | |
 +|**with_graphs**|//​integer//​|only with graphs | |
 +|**editable**|//​integer//​|only with read-write permission. Ignored for SuperAdmins | |
 +|**filter**|//​array//​|Optional filter by host fields| |
 +|**search**|//​array//​|Return hosts by any given host object field pattern ​ | |
 +|**startSearch**|//​integer//​|Search hosts field pattern only in start of the field  | |
 +|**excludeSearch**|//​integer//​|Exclude from result, hosts by given field pattern ​ | |
 +|**searchWildcardsEnabled**|//​integer//​|Search pattern in whole field using wildcards | 1 - enable, 0 - disable|
 +|**output**|//​string//​|Output options | Values: shorten, refer, extend|
 +|**select_groups**|//​string//​|Select host groups| Values: shorten, refer, extend|
 +|**selectParentTemplates**|//​string//​|Select host templates| Values: shorten, refer, extend|
 +|**select_items**|//​string//​|Select host items| Values: shorten, refer, extend|
 +|**select_triggers**|//​string//​|Select host triggers| Values: shorten, refer, extend|
 +|**select_graphs**|//​string//​|Select host graphs| Values: shorten, refer, extend|
 +|**select_dhosts**|//​string//​|Select host related discovery hosts | Values: shorten, refer, extend|
 +|**select_dservices**|//​string//​|Select host related discovery services | Values: shorten, refer, extend|
 +|**select_applications**|//​string//​|Select host applications| Values: shorten, refer, extend|
 +|**select_macros**|//​string//​|Select host macros| Values: shorten, refer, extend|
 +|**select_profile**|//​string//​|Select host profile| Values: shorten, refer, extend|
 +|**countOutput**|//​integer//​|Count hosts, return the number of hosts found | |
 +|**groupCount**|//​integer//​|Return the number of results grouped by given IDs | |
 +|**preservekeys**|//​integer//​|Return hash instead of array |Keys of hash are object IDs |
 +|**sortfield**|//​string//​|Sort by host field |Values: hostid,​host,​status,​dns,​ip |
 +|**sortorder**|//​string//​|Sort order | Values: ASC, DESC|
 +|**limit**|//​int//​|max number of host objects to return | |
 +
 +====Returns====
 +^Parameter^Description^
 +|**result**|Operation successful. Result will contain array of Host objects.|
 +|**error**|In case of any errors|
 +==== Example ====
 +
 +Get hosts details by host name "​Zabbix-server","​Zabbix-server TEST":
 +<code java>
 +{
 +"​jsonrpc":"​2.0",​
 +"​method":"​host.get",​
 +"​params":​{
 + "​output":"​extend",​
 + "​filter":​{
 + "​host":​["​Zabbix-server","​Zabbix-server TEST"]
 + }
 + },
 +"​auth":"​6f38cddc44cfbb6c1bd186f9a220b5a0",​
 +"​id":​2
 +}
 +</​code>​
 +Retrieved host details:
 +
 +<code java>
 +{
 +"​jsonrpc":"​2.0",​
 +"​result":​[{
 + "​maintenances":​[{
 + "​maintenanceid":"​0"​
 + }],
 + "​hostid":"​100100000010017",​
 + "​proxy_hostid":"​0",​
 + "​host":"​ZABBIX-Server",​
 + "​dns":"​ip4-dm",​
 + "​useip":"​1",​
 + "​ip":"​192.168.3.4",​
 + "​port":"​31055",​
 + "​status":"​0",​
 + "​disable_until":"​0",​
 + "​error":"",​
 + "​available":"​1",​
 + "​errors_from":"​0",​
 + "​lastaccess":"​0",​
 + "​inbytes":"​0",​
 + "​outbytes":"​0",​
 + "​useipmi":"​0",​
 + "​ipmi_port":"​623",​
 + "​ipmi_authtype":"​-1",​
 + "​ipmi_privilege":"​2",​
 + "​ipmi_username":"",​
 + "​ipmi_password":"",​
 + "​ipmi_disable_until":"​0",​
 + "​ipmi_available":"​0",​
 + "​snmp_disable_until":"​0",​
 + "​snmp_available":"​0",​
 + "​maintenanceid":"​0",​
 + "​maintenance_status":"​0",​
 + "​maintenance_type":"​0",​
 + "​maintenance_from":"​0",​
 + "​ipmi_ip":"",​
 + "​ipmi_errors_from":"​0",​
 + "​snmp_errors_from":"​0",​
 + "​ipmi_error":"",​
 + "​snmp_error":""​
 +},{
 + "​maintenances":​[{
 + "​maintenanceid":"​0"​
 + }],
 + "​hostid":"​100100000010229",​
 + "​proxy_hostid":"​0",​
 + "​host":"​ZABBIX-Server TEST",
 + "​dns":"​ip4-dm",​
 + "​useip":"​1",​
 + "​ip":"​192.168.3.4",​
 + "​port":"​31055",​
 + "​status":"​0",​
 + "​disable_until":"​0",​
 + "​error":"",​
 + "​available":"​1",​
 + "​errors_from":"​0",​
 + "​lastaccess":"​0",​
 + "​inbytes":"​0",​
 + "​outbytes":"​0",​
 + "​useipmi":"​0",​
 + "​ipmi_port":"​623",​
 + "​ipmi_authtype":"​-1",​
 + "​ipmi_privilege":"​2",​
 + "​ipmi_username":"",​
 + "​ipmi_password":"",​
 + "​ipmi_disable_until":"​0",​
 + "​ipmi_available":"​0",​
 + "​snmp_disable_until":"​0",​
 + "​snmp_available":"​0",​
 + "​maintenanceid":"​0",​
 + "​maintenance_status":"​0",​
 + "​maintenance_type":"​0",​
 + "​maintenance_from":"​0",​
 + "​ipmi_ip":"",​
 + "​ipmi_errors_from":"​0",​
 + "​snmp_errors_from":"​0",​
 + "​ipmi_error":"",​
 + "​snmp_error":""​
 +}],
 +"​id":​2
 +}
 +</​code>​