X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-mq-connection;h=2ed45ca4ac7a7c621c60e5a002cbecd92f044ab4;hb=83535ee3285dd67121a147eb3d7ed3f6ddcf72cc;hp=5d3328cca26ddbf9879ca24d6a45d9cb0fe4c251;hpb=b2fbd79995d78d3c4d98b09953859bbe1d156f08;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-mq-connection b/dsa-nagios-checks/checks/dsa-check-mq-connection index 5d3328c..2ed45ca 100755 --- a/dsa-nagios-checks/checks/dsa-check-mq-connection +++ b/dsa-nagios-checks/checks/dsa-check-mq-connection @@ -61,10 +61,10 @@ if [ "${prefix/[^a-z0-9-]/}" != "$prefix" ]; then exit 3 fi -check_conn () { - sudo -u rabbitmq rabbitmqctl list_queues -p ${vhost} name messages consumers \ - | grep "${prefix}-${host}.debian.org" \ - | while read name messages consumers; do +check_output() { + found=0 + while read name messages consumers; do + found=1 if [ "${name}" != "${prefix}-${host}.debian.org" ]; then echo "Unexpected output: ${name} ${messages} ${consumers}" return 3 @@ -77,8 +77,21 @@ check_conn () { fi return 0 done - echo "${host} not connected to MQ" - return 2 + if [ $found = 0 ]; then + return 2 + fi +} + +check_conn () { + sudo -u rabbitmq rabbitmqctl list_queues -p ${vhost} name messages consumers \ + | grep "${prefix}-${host}.debian.org" \ + | check_output + ret=$? + if [ $ret != 0 ]; then + echo "${host} not connected to MQ" + return 2 + fi + return 0 } check_conn ret=$?