From 6c300f24f0abfca95f8302c31f2e980b5783f475 Mon Sep 17 00:00:00 2001 From: cronekorkn Date: Sat, 24 Sep 2022 14:40:58 +0200 Subject: [PATCH] retry... --- bundles/monitored/files/downtime | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bundles/monitored/files/downtime b/bundles/monitored/files/downtime index ed6957d..8d1bbb7 100644 --- a/bundles/monitored/files/downtime +++ b/bundles/monitored/files/downtime @@ -1,8 +1,10 @@ #!/usr/bin/env python3 from requests import Session +from requests.exceptions import ConnectionError from sys import argv -from time import time +from time import sleep, time + if len(argv) > 1 and argv[1] == "remove": action = "remove" @@ -17,6 +19,18 @@ session = Session() session.auth = ('root', '${icinga_password}') now = int(time()) + +# wait online + +for _ in range(10): + try: + session.get(api_url).raise_for_status() + except ConnectionError as error: + print(f'{error}: retrying...') + sleep(3) + else: + break + # look for existing downtimes response = session.get(