]> git.datanom.net - check_http.git/commitdiff
Fix bug master
authorMichael Rasmussen <mir@datanom.net>
Thu, 7 Dec 2023 13:48:01 +0000 (14:48 +0100)
committerMichael Rasmussen <mir@datanom.net>
Thu, 7 Dec 2023 13:48:01 +0000 (14:48 +0100)
check_actuator_health.py

index 49a91b69777557d4e9bc7abbccf85792dc39b950..ead49145bb66c5b3962134eafcfd9036ce52f743 100644 (file)
@@ -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():
This page took 0.034668 seconds and 5 git commands to generate.