From d6e42272957e44a8bd1cf499c7909b210a16a064 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 7 Jul 2017 14:30:22 +0100 Subject: [PATCH] show-queues: A script to display a summary of what's in the queues. --- show-queues.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 show-queues.py diff --git a/show-queues.py b/show-queues.py new file mode 100755 index 0000000..9a8b4f0 --- /dev/null +++ b/show-queues.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Display the contents of the queues. +# +# Note this cannot display messages which are being processed. +# +# This works by fetching the messages without acknowledging them, +# effectively peeking into the queues. + +import email +import json +import pika + +import config + +connection = pika.BlockingConnection(pika.ConnectionParameters( + host = config.mq_server)) +channel = connection.channel() + +print "patchq_input (Unordered messages):" +while True: + method, _, body = channel.basic_get(queue = 'patchq_input', no_ack = False) + if not method: break + m = email.message_from_string(body) # the email + # Only display the subject line. + print (" %s" % m['Subject']) + +for t in config.tests: + qname = "patchq_test_%s" % t + print ("%s (Threads queued for %s):" % (qname, t)) + while True: + method, _, body = channel.basic_get(queue = qname, no_ack = False) + if not method: break + + msgs = json.loads(body) + msgs = [email.message_from_string(m) for m in msgs] + + print (" Thread:") + for m in msgs: + print (" %s" % m['Subject']) + +print "patchq_reports (Reports):" +while True: + method, _, _ = channel.basic_get(queue = 'patchq_reports', no_ack = False) + if not method: break + + to, subject, ref, content = json.loads(body) + + print (" %s" % subject) + +print +print "Note that messages being processed are not displayed. To see all" +print "messages use ‘rabbitmqctl list_queues’ and other RabbitMQ admin tools." -- 1.8.3.1