From d1d3428a5ac98df5b8a33d4cd76a1852cf986ab5 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Thu, 4 Sep 2014 07:45:39 -0300 Subject: [PATCH] Mark host as up or down before execute script, then script can use this information. Submitted by: Jean Debogue --- usr/local/bin/ping_hosts.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/local/bin/ping_hosts.sh b/usr/local/bin/ping_hosts.sh index 30782b8c52..7126c99989 100755 --- a/usr/local/bin/ping_hosts.sh +++ b/usr/local/bin/ping_hosts.sh @@ -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"