From: Michael Rasmussen Date: Thu, 7 Dec 2023 13:48:01 +0000 (+0100) Subject: Fix bug X-Git-Url: http://git.datanom.net/check_http.git/commitdiff_plain/da5fc43f871a290e2a6513712d894a6aa3810ada?ds=sidebyside;hp=40034215ad3e2801a2a527c639c111ff2c9cfbe8 Fix bug --- 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():