-
Notifications
You must be signed in to change notification settings - Fork 4
/
getProblems.py
executable file
·32 lines (23 loc) · 1.09 KB
/
getProblems.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Get current problems, print out some details
"""
from zabbix.api import ZabbixAPI
zabbixServer = 'http://yourserver/zabbix/'
zabbixUser = 'someuser'
zabbixPass = 'somepass'
zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
problems = zapi.problem.get()
for problem in problems:
trigger = zapi.trigger.get (triggerids=problem['objectid'], selectHosts='extend')
interface = zapi.hostinterface.get(hostids=trigger[0]['hosts'][0]['hostid'])
group = zapi.hostgroup.get(hostids=trigger[0]['hosts'][0]['hostid'])
enabled = "Enabled"
if (trigger[0]['hosts'][0]['status'] == "1"):
enabled = "Disabled"
print "Group:{}; Host:{}; IP:{}; Problem:{}; {}".format(group[1]['name'],
trigger[0]['hosts'][0]['host'],
interface[0]['ip'],
trigger[0]['description'],
enabled )