From 40a819e1d5dc7dda9f0994cb886eef6748e8f8cd Mon Sep 17 00:00:00 2001 From: Stephen Smoogen Date: Thu, 30 May 2019 16:56:26 +0000 Subject: [PATCH] [nagios/datanommer] this is what happens when you have 2 files which are supposeldy the same file. You edit one in nagios_server and miss the one in nagios_client. Bad nagios. Bad --- .../plugins/check_datanommer_timesince.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/roles/nagios_server/files/nagios/plugins/check_datanommer_timesince.py b/roles/nagios_server/files/nagios/plugins/check_datanommer_timesince.py index d4fcef1725..66b4b2866d 100755 --- a/roles/nagios_server/files/nagios/plugins/check_datanommer_timesince.py +++ b/roles/nagios_server/files/nagios/plugins/check_datanommer_timesince.py @@ -2,6 +2,8 @@ """ NRPE check for datanommer/fedmsg health. Given a category like 'bodhi', 'buildsys', or 'git', return an error if datanommer hasn't seen a message of that type in such and such time. +You can alternatively provide a 'topic' which might look like +org.fedoraproject.prod.bodhi.update.comment. Requires: python-dateutil @@ -19,19 +21,24 @@ import sys import json -def query_timesince(category): - cmd = 'datanommer-latest --category %s --timesince' % category +def query_timesince(identifier): + # If it has a '.', then assume it is a topic. + if '.' in identifier: + cmd = 'datanommer-latest --topic %s --timesince' % identifier + else: + cmd = 'datanommer-latest --category %s --timesince' % identifier sys.stderr.write("Running %r\n" % cmd) process = subprocess.Popen(cmd.split(), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() + prefix, stdout = stdout.split("INFO] ", 1) data = json.loads(stdout) return float(data[0]) def main(): - category, warning_threshold, critical_threshold = sys.argv[-3:] - timesince = query_timesince(category) + identifier, warning_threshold, critical_threshold = sys.argv[-3:] + timesince = query_timesince(identifier) warning_threshold = int(warning_threshold) critical_threshold = int(critical_threshold) @@ -43,7 +50,7 @@ def main(): time_strings.append("%d %s" % (value, denomination)) string = ", ".join(time_strings) - reason = "datanommer has not seen a %r message in %s" % (category, string) + reason = "datanommer has not seen a %r message in %s" % (identifier, string) if timesince > critical_threshold: print "CRIT: ", reason