-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathget_Triggers_Hosts.py
48 lines (33 loc) · 1.16 KB
/
get_Triggers_Hosts.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from pyzabbix import ZabbixAPI
import csv
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
hostid = []
hostname = []
triggers=[]
nomehosttrigger = []
severidade = []
dicionario = {'1':'Information', '2':'Warning', '3':'Average', '4':'High', '5':'Disaster'}
url=str(raw_input("Digite a Url: "))
user=str(raw_input("Digite o User: "))
password=str(raw_input("Digite a Senha: "))
zapi = ZabbixAPI(url = url, user = user, password = password)
print(zapi.api_version())
for l in zapi.host.get(output='extend'):
hostname.append(l['host'])
triggers.append('Trigger')
nomehosttrigger.append('Hostname')
severidade.append('Severidade')
for x in hostname:
for item in zapi.trigger.get(output='extend', filter={'host':x}):
nomehosttrigger.append(x)
triggers.append(item['description'])
severidade.append(dicionario[item['priority']])
#data=pd.DataFrame({'Hostname':nomehosttrigger,'Triggers':triggers,'Severidade':severidade})
#data.to_csv('triggers_hosts.csv',index=False)
csv_out = open('Zabbix-Hosts Triggers.csv','wb')
mywriter = csv.writer(csv_out)
for row in zip(nomehosttrigger,triggers,severidade):
mywriter.writerow(row)
csv_out.close()