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 [2020/02/14 11:57]
iivs fixed selectInheritedTags option description (ZBXNEXT-5694)
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 391: Line 391:
 } }
 </​code>​ </​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. Retrieve hosts that have "​Disaster"​ problems.
 +
 Request: Request:
 <code java> <code java>
Line 399: Line 483:
     "​method":​ "​host.get",​     "​method":​ "​host.get",​
     "​params":​ {     "​params":​ {
-        "​output":​ ["​name"​]+        "​output":​ ["​name"​],
         "​severities":​ 5         "​severities":​ 5
     },     },
Line 414: Line 498:
         {         {
             "​hostid":​ "​10160",​             "​hostid":​ "​10160",​
-            "​name":​ "​Zabbix server"​,+            "​name":​ "​Zabbix server"​
         }         }
     ],     ],
Line 422: Line 506:
  
 Retrieve hosts that have "​Average"​ and "​High"​ problems. Retrieve hosts that have "​Average"​ and "​High"​ problems.
 +
 Request: Request:
 <code java> <code java>
Line 428: Line 513:
     "​method":​ "​host.get",​     "​method":​ "​host.get",​
     "​params":​ {     "​params":​ {
-        "​output":​ ["​name"​]+        "​output":​ ["​name"​],
         "​severities":​ [3, 4]         "​severities":​ [3, 4]
     },     },
Line 443: Line 528:
         {         {
             "​hostid":​ "​20170",​             "​hostid":​ "​20170",​
-            "host": "​Database"​,+            "name": "​Database"​
         },         },
         {         {
             "​hostid":​ "​20183",​             "​hostid":​ "​20183",​
-            "host": "​workstation"​,+            "name": "​workstation"​
         }         }
     ],     ],
Line 453: Line 538:
 } }
 </​code>​ </​code>​
 +
 ==== See also ==== ==== See also ====
  
Line 462: 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//​.