Attachment 'check-drbd.sh'

Download

#!/bin/bash
#
# (c) Umberto Nicoletti, 2005
# reports the status of a drbd resource
# http://www.unicolet.org/linux/drbdnagios.html
#
# 300107 Oliver Hookins, Anchor Systems Pty/Ltd:
# - altered to loop over all available devices

DEVICES=`ls /dev/drbd* | sed -e 's/\/dev\/drbd//'`

#########################
#
#       MAIN()
#
#########################

if [ ! -f /proc/drbd ]
then
  echo "CRITICAL: /proc/drbd does not exist"
  exit 1
fi

OUT_CODE=3

for device in $DEVICES
do
        STATUS=`grep "^ [$device]" /proc/drbd`

        CONNECTED=`echo $STATUS | awk -F: '{print $3}'`
        CONSISTENT=`echo $STATUS | awk -F: '{print $5}'`

        if [ "$CONSISTENT" != "Consistent" ] ; then
                echo -n "Device $device consistency: $CONSISTENT;"
                MY_CODE=2;
        elif [ "$CONNECTED" != "Connected st" ] ; then
                echo -n "Device $device status: $CONNECTED;"
                MY_CODE=1;
        else
                echo -n "Device $device: $CONNECTED:$CONSISTENT;"
                MY_CODE=0;
        fi

        if [ "$OUT_CODE" -eq 3 ]
        then
                OUT_CODE=$MY_CODE
        elif [ "$MY_CODE" -gt "$OUT_CODE" ]
        then
                OUT_CODE=$MY_CODE
        fi
done

echo
exit $OUT_CODE;

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2013-05-31 11:14:57, 8.0 KB) [[attachment:IPaddr2_vlan.sh]]
  • [get | view] (2013-05-31 11:14:58, 361.3 KB) [[attachment:LCA2008-talk.odp]]
  • [get | view] (2013-05-31 11:14:58, 832.2 KB) [[attachment:LCA2008-talk.pdf]]
  • [get | view] (2013-05-31 11:14:57, 3.7 KB) [[attachment:alter_mysql_slave]]
  • [get | view] (2013-05-31 11:14:57, 3.7 KB) [[attachment:alter_mysql_slave.sh]]
  • [get | view] (2013-05-31 11:14:57, 1.5 KB) [[attachment:authkeys]]
  • [get | view] (2013-05-31 11:14:57, 1.5 KB) [[attachment:authkeys.txt]]
  • [get | view] (2013-05-31 11:14:58, 1.1 KB) [[attachment:check-drbd.sh]]
  • [get | view] (2013-05-31 11:14:57, 11.4 KB) [[attachment:check_replication.pl]]
  • [get | view] (2013-05-31 11:14:57, 6.1 KB) [[attachment:cib.xml.template]]
  • [get | view] (2013-05-31 11:14:58, 8.0 KB) [[attachment:db-export-mysqlstandby.pl]]
  • [get | view] (2013-05-31 11:14:57, 3.8 KB) [[attachment:drbd.conf.txt]]
  • [get | view] (2013-05-31 11:14:58, 1.3 KB) [[attachment:drbddisk.sh]]
  • [get | view] (2013-05-31 11:14:57, 1.5 KB) [[attachment:ha.cf.txt]]
  • [get | view] (2013-05-31 11:14:58, 9.0 KB) [[attachment:init_mysql_slave.pl]]
  • [get | view] (2013-05-31 11:14:58, 1.2 KB) [[attachment:logd.cf.txt]]
  • [get | view] (2013-05-31 11:14:58, 2.2 KB) [[attachment:lvs-helper.sh]]
  • [get | view] (2013-05-31 11:14:57, 1.8 KB) [[attachment:my.cnf.txt]]
  • [get | view] (2013-05-31 11:14:57, 2.2 KB) [[attachment:myslave.cnf.txt]]
  • [get | view] (2013-05-31 11:14:57, 5.5 KB) [[attachment:mysqld.sh]]
  • [get | view] (2013-05-31 11:14:58, 2.0 KB) [[attachment:mysqlslave.cnf.txt]]
  • [get | view] (2013-05-31 11:14:57, 5.7 KB) [[attachment:mysqlslaved.sh]]
  • [get | view] (2013-05-31 11:14:57, 3.5 KB) [[attachment:write_heartbeat.pl]]

You are not allowed to attach a file to this page.