【问题标题】:getting the active alarms for specific host generated in zabbix when there is fault using zabbix api使用 zabbix api 在出现故障时获取 zabbix 中生成的特定主机的活动警报
【发布时间】:2016-06-21 09:15:17
【问题描述】:

我正在尝试使用 python 创建脚本以在特定交换机端口上存在活动警报时弹出窗口。我使用 zabbix 作为 snmp 系统,我在 python 中使用 zabbix api。到目前为止,我能够通过以下方式获取特定主机的触发器来检索警报:

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

这将返回以下内容:

[{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'},

问题是我无法看到警报的状态是 OK 还是 Problem,因为它显示在 zabbix 的网页中,以便我跟踪它并启动我的弹出窗口。

【问题讨论】:

    标签: python-2.7 zabbix


    【解决方案1】:

    PROBLEM/OK 由 value 属性标识 - 在您的示例中,它设置为 1,因此触发器处于问题状态。

    trigger.get API 文档页面有an example to retrieve only triggers in the problem state

    【讨论】:

    • 感谢您提供此信息。它对我来说工作正常
    猜你喜欢
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多