Tuesday, November 24, 2009

The Pig Ping Script

This is my own personal ping script, feel free to use but please include the credits to the Pig



PigPing.cmd

del falla.txt >nul
del falluto.txt >nul
del timedout.txt > nul
del notresolving.txt >nul
del ok1.txt >nul


for /f %%i in (serverlist.txt) do call :set %%i
type ok1.txt | find /i "problem" >>falla.txt
for /f "tokens=1 delims=;" %%b in (falla.txt) do echo %%b >>falluto.txt
for /f %%y in (falluto.txt) do ping %%y -n 1 | find "timed out"&&echo %%y >>timedout.txt || echo %%y >>notresolving.txt
ren ok1.txt results.csv


:set
set serv=%1
IF [%1]==[] goto :fin


goto :next

:next
for /f "tokens=*" %%z in ('ping %serv% -n 1 ^| find /i "replY" ^|^| echo Problem found Check timedout.txt and notresolving.txt logs') do echo %serv%;"%%z" >>ok1.txt


:eof

:fin





All you need to do is to fill a list of servers (no space after the server names or IP Addresses), one per line.
Then you execute this script. It will create 3 useful files :
Results.csv Open this with excel, this should display a summary of the pinged servers.
Timedout.txt : servers that did not respond correctly (ping request timed out).
notresolving.txt : servers that are not resolving correctly to its IP Address.

0 comments:

Post a Comment