linuxrules
05-12-2004, 23:47
I would like to have an alarm or custom funktion to start if zabbix_suckerd goes down.
I have 2 zabbix server running and if the zabbix_suckerd goes down i dont get any warning.
I think the solution is an shell schript run by cron is enough.
:-)
Jesper
Hi, try this script. I use it within my debianized version of zabbix package.
I know this is not clean code, but it works...
Parameters:
zabbix_check_suckerd num_of_tries sleep_before_tries [email]
We will check if suckerd is runing each sleep_before_tries , tgry to restart it if it goes down and optionaly send email to admin.
Enjoy !
Cut here
-------------------------
#!/bin/sh
NAME=zabbix_suckerd
NAME2=suckerd
MYNAME=`basename $0`
PIDFILE=/var/run/zabbix/check_${NAME2}.pid
doalert () {
if [ -n "$ADMINEMAIL" ]; then
logger "$MYNAME: $NAME died. VERY BAD.. Mailing potential problems to $ADMINEMAIL and exiting.."
tail -30 /var/log/zabbix/${NAME2}.log |mail -s "$0 died. VERY BAD.. Here is some info." "$ADMINEMAIL"
else
logger "$MYNAME died. VERY BAD.. exiting.."
fi
}
#echo $$ >$PIDFILE
if [ -z "$1" ] || [ -z "$2" ]; then
echo -e "\nPreocess to check that $NAME is running."
echo "It checks that sucker processess ar alive and if not, restart them if num_of_tries>0."
echo "Eventualy it sends email to admin that something is wrong."
echo -e "$0 num_of_tries sleep_before_tries [email]\n"
exit 1
fi
if [ -n "$3" ]; then
ADMINEMAIL="$3";
fi
TRIES=$1
SLEEP=$2
sleep $SLEEP
while [ $TRIES -gt 0 ] ; do
while pidof $NAME >/dev/null 2>/dev/null; do
sleep $SLEEP
done
logger "$MYNAME: $NAME died. Trying to recover (`expr $TRIES - 1` tries left)"
/etc/init.d/zabbix-server start$NAME2
sleep $SLEEP
TRIES=`expr $TRIES - 1`
done
if [ $1 -eq 0 ]; then
if pidof $NAME >/dev/null 2>/dev/null; then
exit
fi
fi
doalert
rm - $PIDFILE
exit 1