It is harder to kill a whisper than even a shouted calumny.”
~Mary Stewart

pingcheck.sh

Google+ Pinterest LinkedIn Tumblr +

This little program takes something like the following as infile.txt and pings each endpoint to find the nearest one. Format is:

        <linename> [space]<ipaddress>

(though if you just feed it a list of IP’s, that’ll work too)

paddr1 162.242.211.137

ipaddr2 78.46.223.24

ipaddr3 50.116.40.226

ipaddr4 50.116.23.211

ipaddr5 37.235.1.174

ipaddr6 37.235.1.177

ipaddr7 84.200.69.80

ipaddr8 84.200.70.40

ipaddr9 91.239.100.100

ipaddr10 89.233.43.71

pingcheck.sh
#!/bin/bash
# $1 - source header/label, $2 - IPAddr/hostname
infile=infile.txt
logfile=pingcheck.log

rm $logfile
count=1
cat $infile | while read lineitem; do
        label=$(echo "$lineitem" | awk '{ print $1 }')
        ipaddr=$(echo "$lineitem" | cut -d " " -f2)
        echo -n "$label: " | tee -a $logfile
        ping -c 2 -q $ipaddr | grep "rtt" | cut -d "/" -f5 | tee -a $logfile
        echo " " | tee -a $logfile
done
Share.

Leave A Reply

Secured By miniOrange