zmirror: Add monitoring for personals mirrors.

(imported from commit acb7f2222076d2f3884a2e52c7032cb48fde1757)
This commit is contained in:
Tim Abbott 2013-08-26 15:43:29 -04:00
parent 2249b18081
commit fd96a0b694
2 changed files with 19 additions and 1 deletions

View file

@ -366,6 +366,12 @@ def process_notice(notice, log):
zephyr_class = notice.cls.lower()
if zephyr_class == options.nagios_class:
# Mark that we got the message and proceed
with file(options.nagios_path, "w") as f:
f.write("0\n")
return
if notice.recipient != "":
is_personal = True
# Drop messages not to the listed subscriptions
@ -517,6 +523,8 @@ def zephyr_to_zulip(options):
zephyr_subscribe_autoretry(("message", "*", "%me%"))
if subscribed_to_mail_messages():
zephyr_subscribe_autoretry(("mail", "inbox", "%me%"))
if options.nagios_class:
zephyr_subscribe_autoretry((options.nagios_class, "*", "*"))
if options.use_sessions:
file(options.session_path, "w").write(zephyr._z.dump_session())
@ -961,6 +969,12 @@ def parse_args():
parser.add_option('--session-path',
default=None,
help=optparse.SUPPRESS_HELP)
parser.add_option('--nagios-class',
default=None,
help=optparse.SUPPRESS_HELP)
parser.add_option('--nagios-path',
default=None,
help=optparse.SUPPRESS_HELP)
parser.add_option('--use-sessions',
default=False,
action='store_true',
@ -1029,6 +1043,10 @@ or specify the --api-key-file option.""" % (options.api_key_file,))))
# don't need to read it in
os.environ["HUMBUG_API_KEY"] = api_key
if options.nagios_path is None and options.nagios_class is not None:
logger.error("\n" + "nagios_path is required with nagios_class\n")
sys.exit(1)
zulip_account_email = options.user + "@mit.edu"
import zulip
zulip_client = zulip.Client(

View file

@ -1,5 +1,5 @@
[program:zmirror-USERNAME]
command=python /home/humbug/humbug/bots/zephyr_mirror_backend.py --root-path=/home/humbug/humbug/bots --user=USERNAME --enable-log=/home/humbug/logs/mirror-log-%(program_name)s --use-sessions --session-path=/home/humbug/zephyr_sessions/%(program_name)s --api-key-file=/home/humbug/api-keys/%(program_name)s --ignore-expired-tickets
command=python /home/humbug/humbug/bots/zephyr_mirror_backend.py --root-path=/home/humbug/humbug/bots --user=USERNAME --enable-log=/home/humbug/logs/mirror-log-%(program_name)s --use-sessions --session-path=/home/humbug/zephyr_sessions/%(program_name)s --api-key-file=/home/humbug/api-keys/%(program_name)s --ignore-expired-tickets --nagios-path=/home/humbug/mirror_status/%(program_name)s --nagios-class=zulip-mirror-nagios
priority=200 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; whether/when to restart (default: unexpected)