summaryrefslogtreecommitdiffstats
path: root/usr/local/bin/ping_hosts.sh
diff options
context:
space:
mode:
Diffstat (limited to 'usr/local/bin/ping_hosts.sh')
-rwxr-xr-xusr/local/bin/ping_hosts.sh100
1 files changed, 50 insertions, 50 deletions
diff --git a/usr/local/bin/ping_hosts.sh b/usr/local/bin/ping_hosts.sh
index 8455015..1d893c2 100755
--- a/usr/local/bin/ping_hosts.sh
+++ b/usr/local/bin/ping_hosts.sh
@@ -69,56 +69,56 @@ for TOPING in $PINGHOSTS ; do
echo Processing $DSTIP
# Look for a service being down
ping -c $COUNT -S $SRCIP $DSTIP
- if [ $? -eq 0 ]; then
- # Host is up
- # Read in previous status
- PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP`
- if [ "$PREVIOUSSTATUS" = "DOWN" ]; then
- # Service restored
- 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
- fi
- echo "UP" > /var/db/pingstatus/$DSTIP
- else
- # Host is down
- PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP`
- if [ "$PREVIOUSSTATUS" = "UP" ]; then
- # Service is down
- 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
- fi
- echo "DOWN" > /var/db/pingstatus/$DSTIP
- fi
- echo "Checking ping time $DSTIP"
- # Look at ping values themselves
- PINGTIME=`ping -c 1 -S $SRCIP $DSTIP | awk '{ print $7 }' | grep time | cut -d "=" -f2`
- echo "Ping returned $?"
- echo $PINGTIME > /var/db/pingmsstatus/$DSTIP
- if [ "$THRESHOLD" != "" ]; then
- if [ "$PINGTIME" -gt "$THRESHOLD" ]; then
- echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT"
- echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor
- sh -c $FAILURESCRIPT
- fi
- fi
- # Wan ping time threshold
- WANTIME=`rrdtool fetch /var/db/rrd/wan-quality.rrd AVERAGE -r 120 -s -1min -e -1min | grep ":" | cut -f3 -d" " | cut -d"e" -f1`
- echo "Checking wan ping time $WANTIME"
- echo $WANTIME > /var/db/wanaverage
- if [ "$WANTHRESHOLD" != "" ]; then
- if [ "$WANTIME" -gt "$WANTHRESHOLD" ]; then
- echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT"
- echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor
- sh -c $FAILURESCRIPT
- fi
- fi
- sleep 1
+# if [ $? -eq 0 ]; then
+# # Host is up
+# # Read in previous status
+# PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP`
+# if [ "$PREVIOUSSTATUS" = "DOWN" ]; then
+# # Service restored
+# 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
+# fi
+# echo "UP" > /var/db/pingstatus/$DSTIP
+# else
+# # Host is down
+# PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP`
+# if [ "$PREVIOUSSTATUS" = "UP" ]; then
+# # Service is down
+# 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
+# fi
+# echo "DOWN" > /var/db/pingstatus/$DSTIP
+# fi
+# echo "Checking ping time $DSTIP"
+# # Look at ping values themselves
+# PINGTIME=`ping -c 1 -S $SRCIP $DSTIP | awk '{ print $7 }' | grep time | cut -d "=" -f2`
+# echo "Ping returned $?"
+# echo $PINGTIME > /var/db/pingmsstatus/$DSTIP
+# if [ "$THRESHOLD" != "" ]; then
+# if [ "$PINGTIME" -gt "$THRESHOLD" ]; then
+# echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT"
+# echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor
+# sh -c $FAILURESCRIPT
+# fi
+# fi
+# # Wan ping time threshold
+# WANTIME=`rrdtool fetch /var/db/rrd/wan-quality.rrd AVERAGE -r 120 -s -1min -e -1min | grep ":" | cut -f3 -d" " | cut -d"e" -f1`
+# echo "Checking wan ping time $WANTIME"
+# echo $WANTIME > /var/db/wanaverage
+# if [ "$WANTHRESHOLD" != "" ]; then
+# if [ "$WANTIME" -gt "$WANTHRESHOLD" ]; then
+# echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT"
+# echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor
+# sh -c $FAILURESCRIPT
+# fi
+# fi
+# sleep 1
done
exit 0
OpenPOWER on IntegriCloud