kunsi-remove-hosts #1
1 changed files with 0 additions and 23 deletions
23
service.py
23
service.py
|
@ -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')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue