nagios: use last Received date to determine message age.

If there are delays while routing the email, we don't want to get a
spurious alert.

(imported from commit 3a9e3abf0a4db2b026f797c929f1b46978f1e5e4)
This commit is contained in:
Jessica McKellar
2013-09-26 11:37:16 -04:00
parent 4acddabe10
commit 03fe84aa6a

View File

@@ -35,7 +35,8 @@ def check_for_old_messages(result):
message_uids.sort()
oldest_message = email.message_from_string(result[message_uids[0]]["RFC822"])
receipt_time = time.mktime(email.utils.parsedate_tz(oldest_message.get("Date")))
last_received_string = oldest_message.get_all("Received")[0].split(";", 1)[-1].strip()
receipt_time = email.utils.mktime_tz(email.utils.parsedate_tz(last_received_string))
if time.time() - receipt_time > 60 * 5: # More than 5 minutes old.
return 2, "CRITICAL: email mirror has unprocessed old messages."
return 0, "OK: no unprocessed old messages."