remove unneeded call to api/objects/hosts

This commit is contained in:
Franzi 2021-01-02 14:40:05 +01:00
parent 0e5209a725
commit 93869e042b
Signed by untrusted user: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -32,27 +32,6 @@ def do_api_calls(config):
else: else:
r.raise_for_status() r.raise_for_status()
# hosts
request_url = "{}/v1/objects/hosts".format(config['icinga2_api']['baseurl'])
headers = {
'Accept': 'application/json',
'X-HTTP-Method-Override': 'GET'
}
requestbody = {
"attrs": [ "name", "state" ],
"filter": config['filters']['hosts'],
}
r = requests.get(request_url,
headers=headers,
data=json.dumps(requestbody),
auth=(config['icinga2_api']['username'], config['icinga2_api']['password']),
verify=False)
if (r.status_code == 200):
data['hosts'] = r.json()
else:
r.raise_for_status()
return data return data
@ -89,8 +68,6 @@ def render_services_per_host(host, data):
if service['joins']['host']['state'] == 0: if service['joins']['host']['state'] == 0:
card_header = services_hostname_template.format(host, 'success', 'UP') card_header = services_hostname_template.format(host, 'success', 'UP')
elif service['joins']['host']['state'] == 0:
card_header = services_hostname_template.format(host, 'warning', 'WARNING')
else: else:
card_header = services_hostname_template.format(host, 'danger', 'DOWN') card_header = services_hostname_template.format(host, 'danger', 'DOWN')