-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreview.py
66 lines (55 loc) · 2.29 KB
/
review.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from pyzabbix import ZabbixAPI
import pandas
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
#Criar Classe para instanciar a API do Zabbix
hostIds= []
hostNames= []
hostStatus= []
hostAvailables= []
templates= []
hostAux= []
nvlAlerta = {'1':'Information', '2':'Warning', '3':'Average', '4':'High', '5':'Disaster'}
hostGroup = []
triggers= []
severidade= []
user = raw_input("Digite o User: ")
password = raw_input("Digite a senha: ")
organizacao = raw_input("Digite o nome do cliente: ")
zabbix = ZabbixAPI(raw_input("Digite a URL: "))
zabbix.login(user,password)
for host in zabbix.host.get(output="extend"):
hostNames.append(host['host'])
hostIds.append(host['hostid'])
hostStatus.append('Enable' if host['status'] is '0' else 'disable')
hostAvailables.append('Agent com problema' if host['available'] is '2' else 'Agent nao startado' if host['available'] is '0' else 'Monitorado')
data = pandas.DataFrame({'Hostname':hostNames, 'Status': hostStatus,'Agent': hostAvailables})
data.to_csv(organizacao +'_zabbix_hosts.csv',index=False)
for hostName in hostNames:
for template in zabbix.host.get(selectParentTemplates={'parentTemplates':'name'},filter={'host':hostName}):
if len(template['parentTemplates']) == 0:
hostAux.append(hostName)
templates.append('Sem Templates')
else:
for index in range(0, len(template['parentTemplates'])):
hostAux.append(hostName)
templates.append(template['parentTemplates'][index]['name'])
data=pandas.DataFrame({'Hostname':hostAux,'Template':templates})
data.to_csv(organizacao+'_zabbix_templates.csv',index=False)
hostAux = []
for host in hostNames:
for trigger in zabbix.trigger.get(output='extend', filter={'host':host}):
hostAux.append(host)
triggers.append(trigger['description'])
severidade.append(nvlAlerta[trigger['priority']])
data=pandas.DataFrame({'Hostname':hostAux,'Triggers':triggers,'Severidade':severidade})
data.to_csv(organizacao+'_zabbix_triggers.csv',index=False)
hostAux = []
for host in hostNames:
for group in zabbix.host.get(selectGroups='extend', filter={'host':host}):
for index in range(0, len(group['groups'])):
hostAux.append(index)
hostGroup.append(group['groups'][index]['name'])
data=pandas.DataFrame({'Hostname':host,'Host Group':hostGroup})
data.to_csv(organizacao+'_zabbix_groups.csv',index=False)