Add new file check_ping.sh
This commit is contained in:
parent
8a5bf1b275
commit
63f4f0e428
1 changed files with 17 additions and 0 deletions
17
ping/check_ping.sh
Normal file
17
ping/check_ping.sh
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/sh +x
|
||||||
|
|
||||||
|
HOSTS="1.2.3.4"
|
||||||
|
|
||||||
|
# no ping request
|
||||||
|
COUNT=3
|
||||||
|
|
||||||
|
for myHost in $HOSTS
|
||||||
|
do
|
||||||
|
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
|
||||||
|
if [ $count -eq 0 ]; then
|
||||||
|
# 100% failed
|
||||||
|
echo "$(date) Host : $myHost is down (ping failed)" >> check.log
|
||||||
|
else
|
||||||
|
echo "$(date) Host : $myHost is up (ping sucessful)" >> check.log
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Add table
Add a link
Reference in a new issue