From 20bce8ed11bf057a9c11074a8de40df22ebf972a Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sun, 1 Oct 2017 12:32:19 +0200 Subject: [PATCH] mirror-health: add shutdown check --- modules/roles/files/mirror_health/mirror-health | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/roles/files/mirror_health/mirror-health b/modules/roles/files/mirror_health/mirror-health index 1d4fae0e3..a11c2570d 100755 --- a/modules/roles/files/mirror_health/mirror-health +++ b/modules/roles/files/mirror_health/mirror-health @@ -5,6 +5,7 @@ import requests import time import calendar import logging +import subprocess from email.utils import parsedate logging.basicConfig(level=logging.INFO) @@ -29,6 +30,12 @@ def last_modified(response): lm = calendar.timegm(parsedate(response.headers['last-modified'])) return lm +def check_shutdown(): + if subprocess.call(['dsa-is-shutdown-scheduled']) == 0: + logging.info("considering myself unhealthy, shutdown scheduled") + return False + return True + def check_uptodate(): global latest_ts for host in HOSTS: @@ -48,7 +55,7 @@ def check_uptodate(): while True: start = time.time() - if check_uptodate(): + if check_shutdown() and check_uptodate(): logging.info("considering myself healthy") open(HEALTH_FILE, 'w').write("OK") else: -- 2.20.1