Ad Widget

Collapse

Zabbix API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • insertcoin
    Junior Member
    • Jan 2014
    • 16

    #1

    Zabbix API

    Hi,

    What API call could I do to see if any triggers are currently triggered for a particular host?

    What I am after is to be able to do a call, if any triggers are currently active for a particular host return fail, if no triggers exist to say true.
  • insertcoin
    Junior Member
    • Jan 2014
    • 16

    #2
    Anyone able to help with this?

    I can't seem to be able to pass the api flag only_true or withUnacknowledgedEvents

    Comment

    • tsalle
      Member
      Zabbix Certified Specialist
      • Oct 2012
      • 79

      #3
      Hi,

      Maybe you should use the Event.get method to retrieve all the events with the value = 1 for desired hosts:
      Code:
      {
          "jsonrpc": "2.0",
          "method": "event.get",
          "params": {
              "output": "extend",
              "select_acknowledges": "extend",
              "hostids": "1234",
              "sortfield": ["clock", "eventid"],
              "selectRelatedObject": 1,
              "sortorder": "DESC"
          },
          "auth": "038e1d7b1735c6a5436ee9eae095879e",
          "id": 1
      }

      Comment

      • insertcoin
        Junior Member
        • Jan 2014
        • 16

        #4
        Hi,

        Thanks for the reply.

        I have tried that method, but it returns a lot of information for a host and I can't seem to make sense of it :/

        For an example, if I go to:

        Latest data » Status of triggers » Latest events

        For a single host it shows 1 trigger with the details "High PROBLEM". Guess I looking to do an API call to check if this page has anything on it for a particular host and return a true or false status.

        Comment

        • insertcoin
          Junior Member
          • Jan 2014
          • 16

          #5
          Ahh a little tinkering I figured that the key "Value =" relates to if the trigger is active or not.

          0 = Not triggered
          1 = triggered...

          Setting the parameter:

          only_true = '1'

          seems to be the missing element.

          I used triggerGet (from the http://zabbixapi.confirm.ch/) with the following default params:

          PHP Code:
           $api->setDefaultParams(array(
                  
          'output' => 'extend',
                  
          'select_acknowledges' => 'extend',
                  
          'sortfield' => array('lastchange','status'),
                  
          'selectRelatedObject' => '1',
                  
          'selectLastEvent' => '1',
                  
          'sortorder' => 'DESC',
                  
          'hostids' => '66',
                  
          'only_true' => '1'
                  
          )); 
          Which has given me the required information.

          Comment

          Working...