Ping IP - Montoring Script cmd
Posted on 2006-11-14
Hey Experts -
I am trying to create a script that will continuously ping several IP addresses listed in a text file. I have found a script that worked and tried modifying it so it would continue to ping at certain intervals, however I don't think I have the code right. I want it to ping say.. every 5 minutes or something to that effect - not every second. Also I think my loop is wrong as it is only pinging the first IP in my textfile and not the others. (It works fine however when I modify it for a one time ping.) Can someone take a look at this and help?
This is my first time really scripting something like this.. but I had thought that the -W part meant the pause between pings - but it didn't seem to slow down one bit. If anyone could help explain the -N and -W it would really help.
Note: I don't want to use outside resources as it would mean me having to jump thru hoops to get software approved and all that - for security and simplicity issues - scripting is my best option.
Could anyone also tell me if this method would effect the performance of the server or my machine?
if exist error.txt del error.txt >NUL
for /f "delims=" %%a in ('type myIP.TXT') do call :PROCESS %%a
ping %1 -n 1 -w 20000 >NUL
if ERRORLEVEL 1 goto IPERROR
echo IP: %1 worked
echo IP: %1 is down at %time% >> error.txt