From 12309c61b607ab43a7eccfc998c1c252dd8f26ce Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 6 Mar 2014 13:38:27 -0500 Subject: [PATCH] Remove Nagios monitoring for the old email mirror. (imported from commit fc4d95b12d5ee29438a2d3e7d8d694e8aa21f202) --- .../zulip_internal/files/nagios3/commands.cfg | 5 -- .../files/nagios3/conf.d/services.cfg | 8 -- .../files/nagios_plugins/check_email_mirror | 86 ------------------- 3 files changed, 99 deletions(-) delete mode 100755 puppet/zulip_internal/files/nagios_plugins/check_email_mirror diff --git a/puppet/zulip_internal/files/nagios3/commands.cfg b/puppet/zulip_internal/files/nagios3/commands.cfg index 43b069630b..79cc591c07 100644 --- a/puppet/zulip_internal/files/nagios3/commands.cfg +++ b/puppet/zulip_internal/files/nagios3/commands.cfg @@ -146,11 +146,6 @@ define command { command_line /usr/lib/nagios/plugins/check_by_ssh -l zulip -t 30 -i /var/lib/nagios/.ssh/id_rsa -H $HOSTADDRESS$ -C '/usr/lib/nagios/plugins/check_postgres_backup' } -define command { - command_name check_email_mirror - command_line /usr/lib/nagios/plugins/check_by_ssh -l zulip -t 30 -i /var/lib/nagios/.ssh/id_rsa -H $HOSTADDRESS$ -C '/usr/lib/nagios/plugins/check_email_mirror' -} - define command { command_name check_email_deliverer_process command_line /usr/lib/nagios/plugins/check_by_ssh -l zulip -t 30 -i /var/lib/nagios/.ssh/id_rsa -H $HOSTADDRESS$ -C '/usr/lib/nagios/plugins/check_email_deliverer_process' diff --git a/puppet/zulip_internal/files/nagios3/conf.d/services.cfg b/puppet/zulip_internal/files/nagios3/conf.d/services.cfg index d11fbf904c..c2d0b28613 100644 --- a/puppet/zulip_internal/files/nagios3/conf.d/services.cfg +++ b/puppet/zulip_internal/files/nagios3/conf.d/services.cfg @@ -419,14 +419,6 @@ define service { contact_groups admins } -define service { - use generic-service - host staging - service_description Check email mirror - check_command check_email_mirror!22 - contact_groups admins -} - define service { use generic-service host staging diff --git a/puppet/zulip_internal/files/nagios_plugins/check_email_mirror b/puppet/zulip_internal/files/nagios_plugins/check_email_mirror deleted file mode 100755 index 4962273f62..0000000000 --- a/puppet/zulip_internal/files/nagios_plugins/check_email_mirror +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/python - -""" -Check that the email-mirror management command is running regularly. - -If old messages are in emailgateway@zulip.com's Inbox, the mirror must -not be running or processing messages correctly. -""" - -import email -import time - -from twisted.internet import protocol, reactor, ssl -from twisted.mail import imap4 - -GATEWAY_EMAIL = "emailgateway@zulip.com" -# Application-specific password. -PASSWORD = "xxxxxxxxxxxxxxxx" - -SERVER = "imap.gmail.com" -PORT = 993 - -exit_code = 0 - -def done(_): - reactor.stop() - -def check_for_old_messages(result): - if not result: - return 0, "OK: no unprocessed messages." - - message_uids = result.keys() - if not message_uids: - return 0, "OK: no unprocessed old messages." - message_uids.sort() - - oldest_message = email.message_from_string(result[message_uids[0]]["RFC822"]) - 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." - -def print_nagios_status(result, proto): - status, message = check_for_old_messages(result) - print message - - global exit_code - exit_code = status - - return proto.logout() - -def examine_mailbox(result, proto, mailbox): - # Fetch messages from a particular mailbox. - return proto.fetchMessage("1:*", uid=True).addCallback( - print_nagios_status, proto) - -def select_mailbox(result, proto): - # Select which mailbox we care about. - mbox = filter(lambda x: "INBOX" in x[2], result)[0][2] - return proto.select(mbox).addCallback(examine_mailbox, proto, result) - -def list_mailboxes(res, proto): - # List all of the mailboxes for this account. - return proto.list("","*").addCallback(select_mailbox, proto) - -def login_failed(failure): - print "UNKNOWN: login to email gateway failed." - global exit_code - exit_code = 3 - -def connected(proto): - d = proto.login(GATEWAY_EMAIL, PASSWORD) - d.addCallback(list_mailboxes, proto) - d.addErrback(login_failed) - return d - -def main(): - imap_client = protocol.ClientCreator(reactor, imap4.IMAP4Client) - d = imap_client.connectSSL(SERVER, PORT, ssl.ClientContextFactory()) - d.addCallbacks(connected, login_failed) - d.addBoth(done) - -reactor.callLater(0, main) -reactor.run() -exit(exit_code)