Files
zulip/puppet/zulip-internal/files/nagios_plugins/check_zephyr_mirror
Zev Benjamin dd678465ae [manual] Move puppet modules to the top level
The new puppet.conf file has to be moved into place manually.

(imported from commit 253d9a95386dae8c803a998ce2dc7e8be40c880a)
2013-10-30 15:42:26 -04:00

43 lines
1019 B
Python
Executable File

#!/usr/bin/env python
"""
Nagios plugin to check that Zephyr mirror forwarding is running.
This script just checks the contents of a file. The forwarding test
itself lives in api/bots/check-mirroring and should be run out of cron.
See bots/zephyr-mirror-crontab for the crontab details.
"""
import os
import time
RESULTS_FILE = "/var/lib/nagios_state/check-mirroring-results"
states = {
"OK": 0,
"WARNING": 1,
"CRITICAL": 2,
"UNKNOWN": 3
}
def report(state, data, last_check):
print "%s: Last test run completed at %s\n%s" % (
state, time.strftime("%Y-%m-%d %H:%M %Z", time.gmtime(last_check)),
data)
exit(states[state])
data = file(RESULTS_FILE).read().strip()
if data.split("\n")[-1].strip() == "0":
state = "OK"
else:
state = "CRITICAL"
last_check = os.stat(RESULTS_FILE).st_mtime
time_since_last_check = time.time() - last_check
if time_since_last_check > 60 * 5:
state = "UNKNOWN"
data = "Results file is stale"
report(state, data, last_check)