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
[pastacode lang=”bash” manual=”%23!%2Fbin%2Fbash%0A%23%20%241%20-%20source%20header%2Flabel%2C%20%242%20-%20IPAddr%2Fhostname%0Ainfile%3Dinfile.txt%0Alogfile%3Dpingcheck.log%0A%0Arm%20%24logfile%0Acount%3D1%0Acat%20%24infile%20%7C%20while%20read%20lineitem%3B%20do%0A%20%20%20%20%20%20%20%20label%3D%24(echo%20%22%24lineitem%22%20%7C%20awk%20’%7B%20print%20%241%20%7D’)%0A%20%20%20%20%20%20%20%20ipaddr%3D%24(echo%20%22%24lineitem%22%20%7C%20cut%20-d%20%22%20%22%20-f2)%0A%20%20%20%20%20%20%20%20echo%20-n%20%22%24label%3A%20%22%20%7C%20tee%20-a%20%24logfile%0A%20%20%20%20%20%20%20%20ping%20-c%202%20-q%20%24ipaddr%20%7C%20grep%20%22rtt%22%20%7C%20cut%20-d%20%22%2F%22%20-f5%20%7C%20tee%20-a%20%24logfile%0A%20%20%20%20%20%20%20%20echo%20%22%20%22%20%7C%20tee%20-a%20%24logfile%0Adone” message=”pingcheck.sh” highlight=”” provider=”manual”/]
Post Views: 364