diff options
author | Ralph Bean <rbean@redhat.com> | 2016-01-29 21:42:52 +0000 |
---|---|---|
committer | Ralph Bean <rbean@redhat.com> | 2016-01-29 21:42:57 +0000 |
commit | bcbb477bce301eabe1808e911227c737f1fe8eb8 (patch) | |
tree | 71d9c5c55cb2f9d9c07eb26e09f43ce353d9644f | |
parent | ea7fd2f3e7cf9799203a7db37185ef3c8ec18317 (diff) | |
download | ansible-bcbb477bce301eabe1808e911227c737f1fe8eb8.tar.gz ansible-bcbb477bce301eabe1808e911227c737f1fe8eb8.tar.xz ansible-bcbb477bce301eabe1808e911227c737f1fe8eb8.zip |
Make this timesince script able to handle topics.
-rwxr-xr-x | roles/nagios_client/files/scripts/check_datanommer_timesince.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/roles/nagios_client/files/scripts/check_datanommer_timesince.py b/roles/nagios_client/files/scripts/check_datanommer_timesince.py index 65be3ed03..66b4b2866 100755 --- a/roles/nagios_client/files/scripts/check_datanommer_timesince.py +++ b/roles/nagios_client/files/scripts/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,8 +21,12 @@ 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) @@ -31,8 +37,8 @@ def query_timesince(category): 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) @@ -44,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 |