Search code examples
python-2.7zabbix

getting the active alarms for specific host generated in zabbix when there is fault using zabbix api


I am trying to create script using python to popup window when there is an active alarm on specific switch port. I am using zabbix as snmp system and I am using zabbix api in python. until now I was able to retrieve the alarms by getting the triggers for specific host by:

host = zapi.trigger.get({"host": "SW-1", "only_true": "extend"})

this will return the following:

[{u'status': u'0',
  u'description': u'{HOST.NAME}  GigabitEthernet0/36 down',
  u'state': u'0',
  u'url': u'',
  u'type': u'0',
  u'templateid': u'0',
  u'lastchange': u'1466402478',
  u'value': u'1',
  u'priority': u'4',
  u'triggerid': u'13914',
  u'flags': u'4',
  u'comments': u'',
  u'error': u'',
  u'expression': u'{13644}=2 and {13645}=2'},

The problem is I am not able to see if the status of the alarm is OK or Problem as it shows in the web page of zabbix for me to track it and launch my popup.


Solution

  • PROBLEM/OK is identified by the value property - in your example it's set to 1, so that trigger is in the problem state.

    The trigger.get API documentation page has an example to retrieve only triggers in the problem state.