Ad Widget

Collapse

Checking if host/ip exists before creating new one using API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zabbixfk
    Senior Member
    • Jun 2013
    • 256

    #1

    Checking if host/ip exists before creating new one using API

    Hello All,
    I couldn't find anything related to hosts.exists or something similar on zabbix 3.0 api.
    I am trying to automate something like creating new hosts ( adding ) - just wanted to check if hosts exists before adding - so that duplicates doesn't happen - i have had the cases where two ip's are added in the past.
    Any pointers are greatly helpful. Below is the sample code i am trying - doing things using PHP , and then calling curl for the url.
    Code:
    #check is ip is matching
    $h_request = array(
        'jsonrpc' => '2.0',
        'method' => 'host.get',
        'params' => array(
            'search' => array(
                'ip' => '172.17.70.1',
            ),
        ),
        'auth' => $auth,
    );
    #Get this host name matching atleast
    $h_request = array(
        'jsonrpc' => '2.0',
        'method' => 'host.get',
        'params' => array(
            'search' => array(
                'host' => 'server',
            ),
        ),
        'auth' => $auth,
    );
    #Get this host name matching atleast using filter
    $h_request = array(
        'jsonrpc' => '2.0',
        'method' => 'host.get',
        'params' => array(
            'filter' => array(
                'host' => 'server',
            ),
        ),
        'auth' => $auth,
    );
    Thanks
  • zabbixfk
    Senior Member
    • Jun 2013
    • 256

    #2
    *bump* - can someone reply please. Is this the correct place to post ?

    Thanks

    Comment

    • zabbixfk
      Senior Member
      • Jun 2013
      • 256

      #3
      * Closing this thread *
      - Figured out, i had missed
      Code:
      id=>1
      on the requests.

      Thanks.

      Comment

      Working...