Giuseppe Lavagetto has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/256412

Change subject: ocg: send out an alarm when ocg doesn't respond to health checks
......................................................................

ocg: send out an alarm when ocg doesn't respond to health checks

Bug: T120078
Change-Id: I9f8e948a4548368eb4d51e30c5eb053f416d54c1
---
M modules/ocg/files/nagios/check_ocg_health
1 file changed, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/12/256412/1

diff --git a/modules/ocg/files/nagios/check_ocg_health 
b/modules/ocg/files/nagios/check_ocg_health
index cadb3e8..a594e1b 100755
--- a/modules/ocg/files/nagios/check_ocg_health
+++ b/modules/ocg/files/nagios/check_ocg_health
@@ -25,6 +25,9 @@
 import requests
 import sys
 
+class HTTPError(Exception):
+       pass
+
 def parse_arguments():
        """parse command line arguments into various thresholds
        :returns: dict containing validated arguments
@@ -55,9 +58,9 @@
        try:
                r = requests.get(url, timeout=5)
        except requests.exceptions.RequestException as e:
-               raise StandardError("connection error: %s" % e)
+               raise HTTPError("connection error: %s" % e)
        if r.status_code != 200:
-               raise StandardError("http status %s" % r.status_code)
+               raise HTTPError("http status %s" % r.status_code)
        try:
                json_data = r.json()
        except:
@@ -108,11 +111,14 @@
        args = parse_arguments()
        try:
                data = poll_ocg_server(args.url)
-       except:
-               report = str(sys.exc_info()[1])
+       except HTTPError as e:
+               report = str(e)
+               exit_status = 2
+       except Exception as e:
+               report = str(e)
                exit_status = 1
        else:
-               exit_status,report = run_checks(args, data)
+               exit_status, report = run_checks(args, data)
        if exit_status == 2:
                print "CRITICAL: %s" % report
        elif exit_status == 1:

-- 
To view, visit https://gerrit.wikimedia.org/r/256412
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f8e948a4548368eb4d51e30c5eb053f416d54c1
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <glavage...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to