Ad Widget

Collapse

Zabbix API Search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rreilly
    Member
    • May 2007
    • 61

    #1

    Zabbix API Search

    I am trying to get items by searching on hostid and item name is this possible ? It seems to me the item name is not searchable, but thought i would double check...
    Thanks
    Rob
  • tsalle
    Member
    Zabbix Certified Specialist
    • Oct 2012
    • 79

    #2
    Hi,
    In which langage are you using the API ?
    You should use the search parameter in the item.get query :

    Code:
    {
        "jsonrpc": "2.0",
        "method": "item.get",
        "params": {
            "hostids": "10084",
            "search": {
                "description": "description to search"
            },
            "sortfield": "name"
        },
        "auth": "038e1d7b1735c6a5436ee9eae095879e",
        "id": 1
    }

    Comment

    • rreilly
      Member
      • May 2007
      • 61

      #3
      Hi, I am using php I wanted to specify a hostid and search for an item by name, I found i could not get that to work. I could however get all items for a hostid and filter all but the one i wanted ...
      Robert

      Comment

      • tsalle
        Member
        Zabbix Certified Specialist
        • Oct 2012
        • 79

        #4
        You can use PhpZabbixApi : http://zabbixapi.confirm.ch

        Youre query will be like :

        Code:
        $api = new ZabbixApi('http://zabbix.local/api_jsonrpc.php', 'zabbix', 'admin');
        
        // get all items named "CPU"
        $cpuItems = $api->itemGet(array(
                'hostid'  => $hostid,
                'searchWildcardsEnabled' => true,
                'search' => array('description' => '*CPU*')
            ));

        Comment

        Working...