ignore services on broken hosts
This commit is contained in:
parent
4d8812e657
commit
6d65637676
1 changed files with 10 additions and 6 deletions
10
service
10
service
|
@ -36,6 +36,8 @@ def regenerate():
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
broken_hosts = set()
|
||||||
|
|
||||||
hosts = requests.get(CONFIG["url_hosts"], auth=(CONFIG["api_user"], CONFIG["api_password"]), verify=False).json()
|
hosts = requests.get(CONFIG["url_hosts"], auth=(CONFIG["api_user"], CONFIG["api_password"]), verify=False).json()
|
||||||
serv = requests.get(CONFIG["url_services"], auth=(CONFIG["api_user"], CONFIG["api_password"]), verify=False).json()
|
serv = requests.get(CONFIG["url_services"], auth=(CONFIG["api_user"], CONFIG["api_password"]), verify=False).json()
|
||||||
|
|
||||||
|
@ -45,10 +47,12 @@ def regenerate():
|
||||||
raise KeyError('API call for services did not return any results')
|
raise KeyError('API call for services did not return any results')
|
||||||
|
|
||||||
for host in hosts['results']:
|
for host in hosts['results']:
|
||||||
|
if host['attrs']['problem']:
|
||||||
|
broken_hosts.add(host['attrs']['display_name'])
|
||||||
|
|
||||||
if host['attrs']['downtime_depth'] > 0:
|
if host['attrs']['downtime_depth'] > 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if host['attrs']['problem']:
|
|
||||||
services['services'].append({
|
services['services'].append({
|
||||||
'host': host['attrs']['display_name'],
|
'host': host['attrs']['display_name'],
|
||||||
'service': '-- HOST --',
|
'service': '-- HOST --',
|
||||||
|
@ -64,10 +68,10 @@ def regenerate():
|
||||||
})
|
})
|
||||||
|
|
||||||
for svc in serv['results']:
|
for svc in serv['results']:
|
||||||
if host['attrs']['downtime_depth'] > 0:
|
if svc['attrs']['problem']:
|
||||||
|
if svc['attrs']['downtime_depth'] > 0 or svc['attrs']['host_name'] in broken_hosts:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if svc['attrs']['problem']:
|
|
||||||
services['services'].append({
|
services['services'].append({
|
||||||
'host': svc['attrs']['host_name'],
|
'host': svc['attrs']['host_name'],
|
||||||
'service': svc['attrs']['display_name'],
|
'service': svc['attrs']['display_name'],
|
||||||
|
|
Loading…
Reference in a new issue