dsa-check-mq-connection: Check that all messages have been consumed and that there...
authorStephen Gran <steve@lobefin.net>
Sun, 19 Jan 2014 11:50:56 +0000 (11:50 +0000)
committerStephen Gran <steve@lobefin.net>
Sun, 19 Jan 2014 11:50:56 +0000 (11:50 +0000)
dsa-nagios-checks/checks/dsa-check-mq-connection [new file with mode: 0755]
dsa-nagios-checks/debian/changelog

diff --git a/dsa-nagios-checks/checks/dsa-check-mq-connection b/dsa-nagios-checks/checks/dsa-check-mq-connection
new file mode 100755 (executable)
index 0000000..a245762
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Copyright 2014 Stephen Gran <sgran@debian.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+usage(){
+       ret=$1
+       if [ $ret -gt 0 ]; then
+               echo "Usage: $0 <hostname> <prefix> [<vhost>]" >&2
+       else
+               echo "Usage: $0 <hostname> <prefix> [<vhost>]"
+       fi
+       exit $ret
+}
+
+host=$1
+prefix=$2
+vhost=$3
+
+if [ -z "$host" ] || [ "$host" = "-h" ] ||  [ "$host" = "--help" ]; then
+       usage 3
+fi
+
+if [ -z "$prefix" ] || [ "$prefix" = "-h" ] ||  [ "$prefix" = "--help" ]; then
+       usage 3
+fi
+
+if [ -z "$vhost" ]; then
+       vhost=dsa
+fi
+
+if [ "$vhost" = "-h" ] ||  [ "$vhost" = "--help" ]; then
+       usage 3
+fi
+
+if [ "${host/[^a-z0-9-]/}" != "$host" ]; then
+       echo >&2 "$0: Invalid hostname $1"
+       exit 3
+fi
+
+if [ "${prefix/[^a-z0-9-]/}" != "$prefix" ]; then
+       echo >&2 "$0: Invalid prefix $2"
+       exit 3
+fi
+
+sudo -u rabbitmq rabbitmqctl list_queues -p ${vhost} name messages consumers \
+       | grep "${prefix}-${host}.debian.org" \
+       | while read name messages consumers; do
+       if [ "${name}" != "${prefix}-${host}.debian.org" ]; then
+               echo "Unexpected output: ${name} ${messages} ${consumers}"
+               exit 3
+       fi
+       if [ "${messages}" -gt 0 ] ; then
+               if [ "${consumers}" -eq 0 ]; then
+                       echo "${host} not connected to MQ"
+                       exit 2
+               fi
+       fi
+done
+echo "${host} connected to ${prefix}-${host}.debian.org in ${vhost}"
+exit 0
index 9914100..1d4cdb4 100644 (file)
@@ -1,5 +1,6 @@
 dsa-nagios-checks (96) UNRELEASED; urgency=low
 
+  [ Peter Palfrader ]
   * dsa-check-zone-rrsig-expiration, dsa-check-zone-rrsig-expiration-many:
     Allow supplying the nameservers to start recursion at (per zone).
     This is useful for reverse zones of RFC1918 space.
@@ -20,6 +21,11 @@ dsa-nagios-checks (96) UNRELEASED; urgency=low
     - accept any ds/dnskey combination whose intersection is not empty.
       (previously we required them to match exactly.)
 
+  [ Stephen Gran ]
+  * dsa-check-mq-connection:
+    Check that all messages have been consumed and that there is an active
+    consumer.
+
  -- Peter Palfrader <weasel@debian.org>  Tue, 23 Apr 2013 20:12:09 +0200
 
 dsa-nagios-checks (95) unstable; urgency=low