From: Stephen Gran Date: Tue, 15 Apr 2014 17:36:11 +0000 (+0100) Subject: track line count X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=34f07b6cd885520c793bc75db6f74084e65bda52;p=mirror%2Fdsa-nagios.git track line count Signed-off-by: Stephen Gran --- 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=$?