From da5fc43f871a290e2a6513712d894a6aa3810ada Mon Sep 17 00:00:00 2001 From: Michael Rasmussen Date: Thu, 7 Dec 2023 14:48:01 +0100 Subject: [PATCH 1/1] Fix bug --- check_actuator_health.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/check_actuator_health.py b/check_actuator_health.py index 49a91b6..ead4914 100644 --- a/check_actuator_health.py +++ b/check_actuator_health.py @@ -22,13 +22,13 @@ try: # RHEL8 import urllib3 as urllib # python3-urllib3-1.24.2-5.el8.noarch.rpm python3-urllib3-1.26.5-3.el9.noarch.rpm import json except: - sys.exit(2) + sys.exit(3) ## These will override any args passed to the script normally. Comment out after testing. #testargs = '--help' #testargs = '--version' #testargs = '-vvv' -testing = True +#testing = True OK_RESPONSE = """ { @@ -117,6 +117,7 @@ def main(): keyword = options['keyword'] url = options['url'] agent = options['agent'] + testing = options['testing'] if keyword is None or url is None: message = "Keywork: {0} url: {1}".format(keyword, url) status = 3 @@ -139,17 +140,17 @@ def main(): message = "UP" status = 2 else: - message = gather_message(data) - status = 0 + status, message = gather_message(data) except Exception as e: - print(e) - message = "DOWN" - status = 2 + log.fatal(e) + message = e + status = 3 gtfo(status, message) def gather_message(json_data): """ Assemble error messages """ + status = 2 msg = None try: if 'components' in json_data: @@ -175,10 +176,10 @@ def gather_message(json_data): else: msg = "{0}: {1}".format(component, error) else: - sys.exit(3) + return (3, msg) except: - sys.exit(3) - return msg + return (3, msg) + return (status, msg) def parse_args(): -- 2.39.5