From ea57a5151ca2ce5151aac959b44a6db8541912e3 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 16 Apr 2013 15:22:27 -0400 Subject: [PATCH] check_send_receive: Improve error reporting on receive path. (imported from commit 54eed4286c5ee4830670306be7c018f41dd4f906) --- bots/check_send_receive.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bots/check_send_receive.py b/bots/check_send_receive.py index 5d0d6ce..fad9515 100755 --- a/bots/check_send_receive.py +++ b/bots/check_send_receive.py @@ -76,13 +76,16 @@ def report(state, time, msg=None): print "%s: send time was %s" % (state, time) exit(states[state]) -def send_humbug(sender, message, nagios): +def send_humbug(sender, message): result = sender.send_message(message) - if result["result"] != "success" and nagios: + if result["result"] != "success" and options.nagios: report("CRITICAL", "Error sending Humbug, args were: %s, %s" % (message, result)) def get_humbug(recipient, max_message_id): - return recipient.get_messages({'last': str(max_message_id)})['messages'] + result = recipient.get_messages({'last': str(max_message_id)}) + if result['result'] != "success" and options.nagios: + report("CRITICAL", "Error receiving Humbugs, args were: %s, %s" % (max_message_id, result)) + return result['messages'] # hamlet and othello are default users sender = "hamlet@humbughq.com" @@ -112,7 +115,7 @@ send_humbug(humbug_sender, { "content": msg_to_send, "subject": "time to send", "to": recipient, - }, options.nagios) + }) msg_content = []