-
Notifications
You must be signed in to change notification settings - Fork 0
/
consulta_003.py
31 lines (23 loc) · 899 Bytes
/
consulta_003.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
import apizabbix
'''Novo filtro. Dessa vez, adicionando 'Select Hosts' para fazer a correlação entre dados
e filtro de campos.
English: New filter. This time, adding 'Select Hosts' to make correlation between data and field filter
'''
api = apizabbix.connect()
hostgroups = api.hostgroup.get(
output = 'extend',
excludeSearch=True,
search={'name': 'Templates'
},
selectHosts=['name','host']
)
'''Foi necessário um loop novo a cada novo grupo, já que veio uma lista de
vários dicionários e informações, sendo um para cada host
English: That's was necessary a new loop for each new group, cuz it brought list of many dicionaries and
informations, one for each host
'''
for hostgroup in hostgroups:
print('Grupo: ', hostgroup['name'])
for host in hostgroup['hosts']:
print(' Host: '+host['name']+': '+host['host'])
api.user.logout()