check_send_receive: Improve error reporting on receive path.

(imported from commit 54eed4286c5ee4830670306be7c018f41dd4f906)
This commit is contained in:
Tim Abbott 2013-04-16 15:22:27 -04:00
parent 77c2452813
commit ea57a5151c

View file

@ -76,13 +76,16 @@ def report(state, time, msg=None):
print "%s: send time was %s" % (state, time) print "%s: send time was %s" % (state, time)
exit(states[state]) exit(states[state])
def send_humbug(sender, message, nagios): def send_humbug(sender, message):
result = sender.send_message(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)) report("CRITICAL", "Error sending Humbug, args were: %s, %s" % (message, result))
def get_humbug(recipient, max_message_id): 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 # hamlet and othello are default users
sender = "hamlet@humbughq.com" sender = "hamlet@humbughq.com"
@ -112,7 +115,7 @@ send_humbug(humbug_sender, {
"content": msg_to_send, "content": msg_to_send,
"subject": "time to send", "subject": "time to send",
"to": recipient, "to": recipient,
}, options.nagios) })
msg_content = [] msg_content = []