From e1deeba72ad1b68c188dee4aac1579c02968b3d6 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 7 May 2016 18:38:44 -0700 Subject: [PATCH] nagios: Move cron_file_helper from bots/ to scripts/lib. This ensures the tool is available in Zulip production deployments. --- bots/cron_file_helper.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 bots/cron_file_helper.py diff --git a/bots/cron_file_helper.py b/bots/cron_file_helper.py deleted file mode 100644 index 96713b4..0000000 --- a/bots/cron_file_helper.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python2.7 -import time - -def nagios_from_file(results_file): - """Returns a nagios-appropriate string and return code obtained by - parsing the desired file on disk. The file on disk should be of format - - %s|%s % (timestamp, nagios_string) - - This file is created by various nagios checking cron jobs such as - check-rabbitmq-queues and check-rabbitmq-consumers""" - - data = open(results_file).read().strip() - pieces = data.split('|') - - if not len(pieces) == 4: - state = 'UNKNOWN' - ret = 3 - data = "Results file malformed" - else: - timestamp = int(pieces[0]) - - time_diff = time.time() - timestamp - if time_diff > 60 * 2: - ret = 3 - state = 'UNKNOWN' - data = "Results file is stale" - else: - ret = int(pieces[1]) - state = pieces[2] - data = pieces[3] - - return (ret, "%s: %s" % (state, data)) -