How to monitor vos3000 services and start if vos3000 services stop

If you want to monitor vos3000 services and start if vos3000 services stop .VOS3000 version 2.1.2.0 is stop after some time so you can monitor the vos3000 services  and start it . Here I am using three shell scripts to monitor to vos3000 service and start it. I am checking vos3000 service every 5 second and if stops I am starting with a script and send email alert.

1- I have created watchdog script to check mbx3000d service and send email alert

Linux# nano /etc/voscheck.sh

#!/bin/bash
#
# watchdog
NAME=mbx3000
START=/etc/mbx3000.sh
NOTIFY=your-email-address
NOTIFYCC=your-email-address
GREP=/bin/grep
PS=/bin/ps
NOP=/bin/true
DATE=/bin/date
MAIL=/bin/mail
RM=/bin/rm

$PS -ef|$GREP -v grep|$GREP $NAME >/dev/null 2>&1
case “$?” in
0)
# It is running in this case so we do nothing.
$NOP
;;
1)
echo “$NAME is NOT RUNNING. Starting $NAME and sending notices.”
$START 2>&1 >/dev/null &
NOTICE=/tmp/watchdog.txt
echo “$NAME was not running and was started on `$DATE`” > $NOTICE
$MAIL -n -s “watchdog notice” -c $NOTIFYCC $NOTIFY < $NOTICE
$RM -f $NOTICE
;;
esac

exit

2- create script for start mbx3000 service

Linux# nano /etc/mbx3000.sh

#!/bin/bash
service mbx3000d start

3- check service every 5 second

Linux# nano /etc/check5.sh

#!/bin/bash
while true
do
/etc/voscheck.sh
sleep 5
done

4-execute the script in background

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *