Drbd verification
De BlaxWiki
Révision datée du 23 septembre 2013 à 10:33 par Admin (discussion | contributions) (a déplacé Check Drbd vers Drbd verification)
Ce script vérifie l'état de la synchro drdb, certaines lignes concernent de la supervision spécifique, elles peuvent etre ignorées. La variable RESSOURCE_LIST définir le nombre de "partition" drbd" que retourne cat /proc/drbd.
#!/bin/sh
PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin
VC=/opt/agarik/Vision/bin/bb_send_raw
VCDISPLAY=supervision.agarik.com
VCTARGET="hv1,ods-lamp,cnrs"
VCSERVICE=drbd
LOG=/var/log/chkdrbd.log
RESSOURCE_LIST="0 1"
# extract informations from drbd
exec > $LOG
exec 2>&1
cat /proc/drbd
# check each device
for device in $RESSOURCE_LIST ; do
device_info=`cat $LOG | grep -e "^ $device:"`
# Check connection state
connection_state=`echo $device_info | awk '{print $2}'`
if [ "$connection_state" != "cs:Connected" ]; then
cs_state=1
else
cs_state=0
fi
# Check role
roles=`echo $device_info | awk '{print $3}'`
if [ "$roles" != "ro:Primary/Primary" ]; then
ro_state=1
else
ro_state=0
fi
# Check Disk States
disk=`echo $device_info | awk '{print $4}'`
if [ "$disk" != "ds:UpToDate/UpToDate" ]; then
ds_state=1
else
ds_state=0
fi
# Get the final color
if [ $cs_state -eq 0 -a $ro_state -eq 0 -a $ds_state -eq 0 ]; then
device_state="${device_state}0"
else
device_state="${device_state}1"
fi
done
if [ $device_state -ne 000 ]; then
VCCOLOR=red
else
VCCOLOR=green
fi
VCDATA="status+15 $VCTARGET.$VCSERVICE $VCCOLOR `/bin/date` $VCSERVICE
`cat $LOG`"
$VC $VCDISPLAY "$VCDATA"