File check_rabbitmq-perfdata.patch of Package monitoring-plugins-rabbitmq
commit 2b4029d2c44f8dc90fc56436add60e8634f79ed2
Author: Ruediger Oertel <ro@suse.de>
Date: Tue Nov 26 16:54:00 2019 +0100
expand perfdata
diff --git a/check_rabbitmq b/check_rabbitmq
index 97bdd88..9ccaa96 100755
--- a/check_rabbitmq
+++ b/check_rabbitmq
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/python2
from optparse import OptionParser
import shlex
import subprocess
@@ -67,13 +67,14 @@ def check_connection_count(critical=0, warning=0):
try:
count = len(RabbitCmdWrapper.list_connections())
if count >= critical:
- print "CRITICAL - Connection Count %d" % count
+ print "CRITICAL - Connection Count %d" % count,
sys.exit(2)
elif count >= warning:
- print "WARNING - Connection Count %d" % count
+ print "WARNING - Connection Count %d" % count,
sys.exit(1)
else:
- print "OK - Connection Count %d" % count
+ print "OK - Connection Count %d" % count,
+ print "| connection_count=%d" % count
except Exception, err:
print "CRITICAL - %s" % err
@@ -86,22 +87,27 @@ def check_queues_count(critical=1000, warning=1000):
try:
critical_q = []
warning_q = []
+ perf_q = []
results = RabbitCmdWrapper.list_queues()
for queue in results:
- if len(queue) == 2:
+ if len(queue) == 2:
count = int(queue[1])
if count >= critical:
- critical_q.append("%s: %s" % (queue[0], count))
+ critical_q.append("%s: %s" % (queue[0], count)),
elif count >= warning:
- warning_q.append("%s: %s" % (queue[0], count))
+ warning_q.append("%s: %s" % (queue[0], count)),
+ perf_q.append("'%s'=%s " % (queue[0], count)),
if critical_q:
- print "CRITICAL - %s" % ", ".join(critical_q)
+ print "CRITICAL - %s" % ", ".join(critical_q),
+ print "| %s" % ", ".join(perf_q)
sys.exit(2)
elif warning_q:
- print "WARNING - %s" % ", ".join(warning_q)
+ print "WARNING - %s" % ", ".join(warning_q),
+ print "| %s" % ", ".join(perf_q)
sys.exit(1)
else:
- print "OK - NO QUEUES EXCEED THRESHOLDS"
+ print "OK - NO QUEUES EXCEED THRESHOLDS",
+ print "| %s" % ", ".join(perf_q)
sys.exit(0)
except Exception, err:
print "CRITICAL - %s" % err
@@ -122,13 +128,13 @@ def check_mem_usage(critical=75, warning=50):
percent_usage = int(100 * memory_used / memory_limit)
if percent_usage > critical:
- print "CRITICAL - RABBITMQ RAM USAGE at %i%% of max|TOTAL=%iKB;;;; USED=%iKB;;;;" % (percent_usage, memory_limit, memory_used)
+ print "CRITICAL - RABBITMQ RAM USAGE at %i%% of max|TOTAL=%iKB;;;; USED=%iKB;;;; mem_usage=%s%%;%s;%s;" % (percent_usage, memory_limit, memory_used, percent_usage, warning, critical)
sys.exit(2)
elif percent_usage > warning:
- print "WARNING - RABBITMQ RAM USAGE at %i%% of max|TOTAL=%iKB;;;; USED=%iKB;;;;" % (percent_usage, memory_limit, memory_used)
+ print "WARNING - RABBITMQ RAM USAGE at %i%% of max|TOTAL=%iKB;;;; USED=%iKB;;;; mem_usage=%s%%;%s;%s;" % (percent_usage, memory_limit, memory_used, percent_usage, warning, critical)
sys.exit(1)
else:
- print "OK - RABBITMQ RAM USAGE at %i%% of max|TOTAL=%iKB;;;; USED=%iKB;;;;" % (percent_usage, memory_limit, memory_used)
+ print "OK - RABBITMQ RAM USAGE at %i%% of max|TOTAL=%iKB;;;; USED=%iKB;;;; mem_usage=%s%%;%s;%s;" % (percent_usage, memory_limit, memory_used, percent_usage, warning, critical)
sys.exit(0)
except Exception, err: