diff --git a/service b/service index e4f38d0..f05e99d 100755 --- a/service +++ b/service @@ -36,6 +36,8 @@ def regenerate(): } try: + broken_hosts = set() + 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() @@ -45,10 +47,12 @@ def regenerate(): raise KeyError('API call for services did not return any results') for host in hosts['results']: - if host['attrs']['downtime_depth'] > 0: - continue - if host['attrs']['problem']: + broken_hosts.add(host['attrs']['display_name']) + + if host['attrs']['downtime_depth'] > 0: + continue + services['services'].append({ 'host': host['attrs']['display_name'], 'service': '-- HOST --', @@ -64,10 +68,10 @@ def regenerate(): }) for svc in serv['results']: - if host['attrs']['downtime_depth'] > 0: - continue - if svc['attrs']['problem']: + if svc['attrs']['downtime_depth'] > 0 or svc['attrs']['host_name'] in broken_hosts: + continue + services['services'].append({ 'host': svc['attrs']['host_name'], 'service': svc['attrs']['display_name'],