kunsi-remove-hosts #1

Merged
sophie merged 3 commits from kunsi-remove-hosts into main 2021-01-02 13:41:42 +00:00
Showing only changes of commit 93869e042b - Show all commits

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')