Added healtcheck "down" requests, send empty draeger api request if data not parseable
This commit is contained in:
parent
4ea63d5623
commit
f36f327bf1
14
main.py
14
main.py
@ -29,6 +29,7 @@ def check_email():
|
||||
|
||||
status, messages = mail.search(None, 'UNSEEN SUBJECT "Nachricht von DLRG Stuttgart"')
|
||||
|
||||
try:
|
||||
mail_ids = messages[0].split()
|
||||
|
||||
for mail_id in mail_ids:
|
||||
@ -64,15 +65,26 @@ def check_email():
|
||||
|
||||
print(r.status_code)
|
||||
print(r.json())
|
||||
except Exception as e:
|
||||
data = {}
|
||||
data["apiKey"] = DRAEGER_API_KEY
|
||||
r = requests.post('https://einsatzmeldesystem.de/ems/inbound/deployment/universal/', json=data)
|
||||
|
||||
r = requests.get(HEALTHCHECK_URL + "?status=down&msg=Can not parse data. Alarming with empty data&ping=")
|
||||
print(r.status_code)
|
||||
|
||||
mail.logout()
|
||||
except Exception as e:
|
||||
print(f'Fehler: {e}')
|
||||
|
||||
r = requests.get(HEALTHCHECK_URL + "?status=down&msg=Can not connect to mail server&ping=")
|
||||
print(r.status_code)
|
||||
|
||||
if __name__ == "__main__":
|
||||
while True:
|
||||
check_email()
|
||||
|
||||
r = requests.get(HEALTHCHECK_URL)
|
||||
r = requests.get(HEALTHCHECK_URL + "?status=up&msg=OK&ping=")
|
||||
print(r.status_code)
|
||||
|
||||
time.sleep(CHECK_INTERVAL)
|
||||
|
Loading…
Reference in New Issue
Block a user