Merge "Handle non-uniform queue stats output"
This commit is contained in:
commit
99fd28ccc1
|
@ -29,10 +29,10 @@ def gen_data_lines(filename):
|
|||
def gen_stats(data_lines):
|
||||
for line in data_lines:
|
||||
try:
|
||||
vhost, queue, _, _, m_all, _ = line.split(None, 5)
|
||||
vhost, queue, _, _, m_all, _, _ = line.split(None, 6)
|
||||
except ValueError:
|
||||
print("ERROR: problem parsing the stats file")
|
||||
sys.exit(2)
|
||||
print("ERROR: problem parsing the line {}".format(line))
|
||||
continue
|
||||
assert m_all.isdigit(), ("Message count is not a number: {0!r}"
|
||||
.format(m_all))
|
||||
yield vhost, queue, int(m_all)
|
||||
|
|
|
@ -44,10 +44,10 @@ if [ ! -d $LOG_DIR ]; then
|
|||
mkdir -p $LOG_DIR
|
||||
fi
|
||||
TMP_DATA_FILE=$(mktemp -p ${DATA_DIR})
|
||||
echo "#Vhost Name Messages_ready Messages_unacknowledged Messages Consumers Memory Time" > ${TMP_DATA_FILE}
|
||||
echo "#Vhost Name Messages_ready Messages_unacknowledged Messages Consumers Memory State Time" > ${TMP_DATA_FILE}
|
||||
/usr/sbin/rabbitmqctl -q list_vhosts | \
|
||||
while read VHOST; do
|
||||
/usr/sbin/rabbitmqctl -q list_queues -p $VHOST name messages_ready messages_unacknowledged messages consumers memory | \
|
||||
/usr/sbin/rabbitmqctl -q list_queues -p $VHOST name messages_ready messages_unacknowledged messages consumers memory state | \
|
||||
awk "{print \"$VHOST \" \$0 \" $(date +'%s') \"}" >> ${TMP_DATA_FILE} 2>${LOG_DIR}/list_queues.log
|
||||
done
|
||||
mv ${TMP_DATA_FILE} ${DATA_FILE}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import unittest
|
||||
|
||||
import check_rabbitmq_queues
|
||||
|
||||
|
||||
class TestCheckRabbitmqQueues(unittest.TestCase):
|
||||
def test_gen_stats(self):
|
||||
incomplete_queue = ["landscape "
|
||||
"landscape.notifications-queue."
|
||||
"aed6fb68-b1ff-4a68-980e-df6adf786beb "
|
||||
"DOWN 1572621605"]
|
||||
x = list(check_rabbitmq_queues.gen_stats(incomplete_queue))
|
||||
self.assertEqual(x, [])
|
||||
|
||||
complete_queue = ["landscape "
|
||||
"landscape.notifications-queue."
|
||||
"b9557ad1-9908-425e-a860-d424e34f63d7 "
|
||||
"0 0 0 0 34952 RUNNING 1572621605"]
|
||||
y = list(check_rabbitmq_queues.gen_stats(complete_queue))
|
||||
self.assertEqual(y, [("landscape",
|
||||
"landscape.notifications-queue."
|
||||
"b9557ad1-9908-425e-a860-d424e34f63d7",
|
||||
0)])
|
Loading…
Reference in New Issue