#!/usr/bin/env python

"""
Nagios plugin to check that the rabbitmq has the correct number of consumers.

This script just checks the contents of /var/lib/nagios_state/check-rabbitmq-consumers,
which is generated by scripts/nagios/check-rabbitmq-consumers.

It is run by cron and can be found at puppet/zulip/files/cron.d/rabbitmq-numconsumers
"""
from __future__ import print_function

import sys

sys.path.append('/home/zulip/deployments/current/scripts/nagios')
from cron_file_helper import nagios_from_file

if len(sys.argv) < 2:
    print("Please pass the name of the consumer file to check")
    exit(1)

RESULTS_FILE = "/var/lib/nagios_state/check-rabbitmq-consumers-%s" % (sys.argv[1])

ret, result = nagios_from_file(RESULTS_FILE)

print(result)
exit(ret)
