summaryrefslogtreecommitdiffstats
path: root/usr/local/bin
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-12-24 12:06:51 -0200
committerRenato Botelho <garga@FreeBSD.org>2013-12-24 12:16:40 -0200
commit98864780199e92ab541e69ee3cbce7d9256604df (patch)
tree3c54be77a083ecddaf10549742bfda74d711d44d /usr/local/bin
parente049c5e74f009430e22e446f149a552d00846d7a (diff)
downloadpfsense-98864780199e92ab541e69ee3cbce7d9256604df.zip
pfsense-98864780199e92ab541e69ee3cbce7d9256604df.tar.gz
On first run REVIOUSSTATUS doesn't exist, so it cannot be UP or DOWN, invert the logic to fix this. While I'm here, check if file exists before cat it
Diffstat (limited to 'usr/local/bin')
-rwxr-xr-xusr/local/bin/ping_hosts.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr/local/bin/ping_hosts.sh b/usr/local/bin/ping_hosts.sh
index 949a843..c8538a6 100755
--- a/usr/local/bin/ping_hosts.sh
+++ b/usr/local/bin/ping_hosts.sh
@@ -75,12 +75,15 @@ for TOPING in $PINGHOSTS ; do
fi
echo Processing $DSTIP
# Look for a service being down
+ # Read in previous status
+ PREVIOUSSTATUS=""
+ if [ -f "/var/db/pingstatus/${DSTIP}" ]; then
+ PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP`
+ fi
$PINGCMD -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
+ if [ "$PREVIOUSSTATUS" != "UP" ]; then
# Service restored
if [ "$SERVICERESTOREDSCRIPT" != "" ]; then
echo "$DSTIP is UP, previous state was DOWN .. Running $SERVICERESTOREDSCRIPT"
@@ -91,8 +94,7 @@ for TOPING in $PINGHOSTS ; do
fi
else
# Host is down
- PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP`
- if [ "$PREVIOUSSTATUS" = "UP" ]; then
+ if [ "$PREVIOUSSTATUS" != "DOWN" ]; then
# Service is down
if [ "$FAILURESCRIPT" != "" ]; then
echo "$DSTIP is DOWN, previous state was UP .. Running $FAILURESCRIPT"
OpenPOWER on IntegriCloud