Make this timesince script able to handle topics.
This commit is contained in:
parent
ea7fd2f3e7
commit
bcbb477bce
1 changed files with 11 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue