Faidon Liambotis has uploaded a new change for review. https://gerrit.wikimedia.org/r/115211
Change subject: check_cert: catch SSLErrors and print them as such ...................................................................... check_cert: catch SSLErrors and print them as such Catch SSLErrors (like e.g. "certificate verify failed") and raise them as such, exiting with a CRITICAL error code. Beats unknown WARNINGs with Tracebacks in their message body. Change-Id: I31b5ce63092a4bd843a1fe54a8800e1facfe250a --- M files/icinga/check_cert 1 file changed, 9 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/11/115211/1 diff --git a/files/icinga/check_cert b/files/icinga/check_cert index 34c4603..a496d92 100644 --- a/files/icinga/check_cert +++ b/files/icinga/check_cert @@ -21,11 +21,15 @@ sock.connect((HOST, PORT)) # It is required to check for validity to pull the peer cert -sock = ssl.wrap_socket(sock, - cert_reqs = ssl.CERT_REQUIRED, - ca_certs = "/etc/ssl/certs/" + args[2] - ) -cert = sock.getpeercert() +try: + sock = ssl.wrap_socket(sock, + cert_reqs = ssl.CERT_REQUIRED, + ca_certs = "/etc/ssl/certs/" + args[2] + ) + cert = sock.getpeercert() +except ssl.SSLError, e: + print "SSL error: %s" % e + sys.exit(2) expire = datetime.datetime(*time.strptime(cert['notAfter'], "%b %d %H:%M:%S %Y GMT")[0:5]) # Send a warning if the cert expires in the next four weeks -- To view, visit https://gerrit.wikimedia.org/r/115211 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I31b5ce63092a4bd843a1fe54a8800e1facfe250a Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Faidon Liambotis <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
