From 05670ac2bbff5241033c6fdd19196837fb0ba5df Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Fri, 11 Jun 2021 16:49:12 +0200 Subject: [PATCH] bundles/icinga2: less code for icinga statusmonitor --- bundles/icinga2/files/icinga_statusmonitor.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bundles/icinga2/files/icinga_statusmonitor.py b/bundles/icinga2/files/icinga_statusmonitor.py index 9088fb6..e816ada 100644 --- a/bundles/icinga2/files/icinga_statusmonitor.py +++ b/bundles/icinga2/files/icinga_statusmonitor.py @@ -8,23 +8,18 @@ app = Flask(__name__) @app.route('/status') def statuspage(): + everything_fine = True try: check_output(['/usr/lib/nagios/plugins/check_procs', '-C', 'icinga2', '-c', '1:']) - - # check_output will raise an exception if there is a non-zero status - icinga_is_fine = True except: - icinga_is_fine = False + everything_fine = False try: check_output(['/usr/lib/nagios/plugins/check_procs', '-C', 'postgres', '-c', '1:']) - - # check_output will raise an exception if there is a non-zero status - postgres_is_fine = True except: - postgres_is_fine = False + everything_fine = False - if icinga_is_fine and postgres_is_fine: + if everything_fine: return 'OK', 200 return 'Something is wrong!', 500