Created
July 12, 2018 08:10
-
-
Save ferdousulhaque/ff169a1920321213abff9a4325de5f21 to your computer and use it in GitHub Desktop.
Bash Ping Checking Script with Delay and Count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Declarations | |
times=58 | |
ip=IP | |
while [ 1 ] | |
do | |
# Executions | |
timestamp=$(date '+%Y-%m-%d %H:%M:%S') | |
result=$(ping -i 1 -c $times $ip | grep 'received') | |
packetloss=$(echo $result| awk '{print $6}') | |
if [ "$packetloss" != "0%" ]; then | |
echo "Ping Loss "$packetloss" at "$timestamp "\n " $result >> /home/user/ping_log_source_to_destination.log | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment