root / plugins / qpid / qpid_enqueuebytes @ c87caf6c
Historique | Voir | Annoter | Télécharger (1,23 ko)
| 1 |
#!/usr/bin/env python |
|---|---|
| 2 |
# |
| 3 |
# Plugin to monitor Apache Qpid |
| 4 |
# - graph ingest rate (bytes/sec) of queue(s) specified in config |
| 5 |
# |
| 6 |
# Parameters understood: |
| 7 |
# |
| 8 |
# queues (required) - space separated list of queues to display (regex allowed) |
| 9 |
# |
| 10 |
# Made by Jimmy Jones (jimmyjones2 AT gmx DOT co DOT uk) |
| 11 |
# |
| 12 |
# Licence: GPLv2 |
| 13 |
# |
| 14 |
|
| 15 |
import re |
| 16 |
import sys |
| 17 |
import os |
| 18 |
from qmf.console import Session |
| 19 |
|
| 20 |
if not "queues" in os.environ: |
| 21 |
print >> sys.stderr, "Missing env.queues in config" |
| 22 |
sys.exit(-1) |
| 23 |
|
| 24 |
output_queue = [] |
| 25 |
sess = Session() |
| 26 |
broker = sess.addBroker() |
| 27 |
queues = sess.getObjects(_class="queue", _package="org.apache.qpid.broker") |
| 28 |
for q in queues: |
| 29 |
for match in os.environ["queues"].split(" "):
|
| 30 |
if re.match(match, q.name): |
| 31 |
output_queue.append(re.sub('[^a-zA-Z0-9_]', '_', q.name))
|
| 32 |
|
| 33 |
if len(sys.argv) > 1 and sys.argv[1] == "config": |
| 34 |
print "graph_category Qpid"; |
| 35 |
print "graph_title Enqueue data rate"; |
| 36 |
print "graph_vlabel bytes/second" |
| 37 |
for queue in output_queue: |
| 38 |
print "%s.label %s" % (queue, queue) |
| 39 |
print "%s.min 0" % queue |
| 40 |
print "%s.type COUNTER" % queue |
| 41 |
else: |
| 42 |
for q in queues: |
| 43 |
qname = re.sub('[^a-zA-Z0-9_]', '_', q.name)
|
| 44 |
if qname in output_queue: |
| 45 |
print "%s.value %u" % (qname, q.byteTotalEnqueues) |
| 46 |
|
| 47 |
sess.delBroker(broker) |
| 48 |
|
