From 63f4f0e4289e31db725871bec8388cebba1225e5 Mon Sep 17 00:00:00 2001 From: petbau Date: Tue, 10 Dec 2019 16:58:53 +0100 Subject: [PATCH] Add new file check_ping.sh --- ping/check_ping.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ping/check_ping.sh diff --git a/ping/check_ping.sh b/ping/check_ping.sh new file mode 100644 index 0000000..81cf25b --- /dev/null +++ b/ping/check_ping.sh @@ -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 \ No newline at end of file