parent
7941b3e6ac
commit
ab260fc6e0
|
@ -20,9 +20,16 @@ def main(args):
|
||||||
|
|
||||||
# Get all checks
|
# Get all checks
|
||||||
objects = ["hosts", "services"]
|
objects = ["hosts", "services"]
|
||||||
for object in objects:
|
for obj in objects:
|
||||||
response = requests.get(url + "/objects/" + object, auth=(args.username, args.password), verify=not args.insecure)
|
for i in range(3):
|
||||||
|
try:
|
||||||
|
response = requests.get(url + "/objects/" + obj, auth=(args.username, args.password), verify=not args.insecure)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
break
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
logging.error(f'Failed to reach Icinga2: {e}')
|
||||||
|
logging.error('Sleeping 60 seconds')
|
||||||
|
time.sleep(60)
|
||||||
|
|
||||||
checks = response.json()["results"]
|
checks = response.json()["results"]
|
||||||
|
|
||||||
|
@ -40,9 +47,9 @@ def main(args):
|
||||||
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
|
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
|
||||||
next_check_time = last_check_time + check_interval + check_timeout
|
next_check_time = last_check_time + check_interval + check_timeout
|
||||||
|
|
||||||
if object == 'services':
|
if obj == 'services':
|
||||||
check_filter = f'host.name=="{check["attrs"]["host_name"]}" && service.name=="{check["attrs"]["name"]}"'
|
check_filter = f'host.name=="{check["attrs"]["host_name"]}" && service.name=="{check["attrs"]["name"]}"'
|
||||||
elif object == 'hosts':
|
elif obj == 'hosts':
|
||||||
check_filter = f'host.name=="{check["name"]}"'
|
check_filter = f'host.name=="{check["name"]}"'
|
||||||
else:
|
else:
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Icinga2 fail overdue services.
|
Description=Icinga2 fail overdue services.
|
||||||
After=network.target
|
Wants=icinga2.service icinga-director.service
|
||||||
|
Requires=icinga2.service icinga-director.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=flask
|
User=flask
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Icinga to Kuma converter.
|
Description=Icinga to Kuma converter.
|
||||||
After=network.target
|
Wants=icinga2.service icinga-director.service
|
||||||
|
Requires=icinga2.service icinga-director.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=flask
|
User=flask
|
||||||
|
|
Loading…
Reference in New Issue