Mark host as up or down before execute script, then script can use this information.

Submitted by: 	Jean Debogue <jean@wedebugyou.com>
This commit is contained in:
Renato Botelho 2014-09-04 07:45:39 -03:00
parent 990162e36c
commit 1b5675a77e
1 changed files with 2 additions and 2 deletions

View File

@ -85,23 +85,23 @@ for TOPING in $PINGHOSTS ; do
# Host is up
if [ "$PREVIOUSSTATUS" != "UP" ]; then
# Service restored
echo "UP" > /var/db/pingstatus/$DSTIP
if [ "$SERVICERESTOREDSCRIPT" != "" ]; then
echo "$DSTIP is UP, previous state was DOWN .. Running $SERVICERESTOREDSCRIPT"
echo "$DSTIP is UP, previous state was DOWN .. Running $SERVICERESTOREDSCRIPT" | logger -p daemon.info -i -t PingMonitor
sh -c $SERVICERESTOREDSCRIPT
fi
echo "UP" > /var/db/pingstatus/$DSTIP
fi
else
# Host is down
if [ "$PREVIOUSSTATUS" != "DOWN" ]; then
# Service is down
echo "DOWN" > /var/db/pingstatus/$DSTIP
if [ "$FAILURESCRIPT" != "" ]; then
echo "$DSTIP is DOWN, previous state was UP .. Running $FAILURESCRIPT"
echo "$DSTIP is DOWN, previous state was UP .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor
sh -c $FAILURESCRIPT
fi
echo "DOWN" > /var/db/pingstatus/$DSTIP
fi
fi
echo "Checking ping time $DSTIP"