Pages

Thursday, September 21, 2017

Cool Little Batch File to Log Your Crappy ISP

 Tried this in Windows 10.  I just spent all day with the internet winking on and off, and wanted to get a feeling for the extent of the outages.  Also sometimes they were hard down, and other times the DNS servers just stopped working.

Enjoy...


@echo off
cls
set Address=google.com
set ThisDate=%date%A
echo %ThisDate%

:Loop
timeout /t 60

if  "%date%" NEQ "%ThisDate%" (
echo %date% >>logfile.log
set ThisDate=%date%
echo %ThisDate%
)

echo %time% >>logfile.log

echo Pinging %Address%
%SystemRoot%\system32\ping.exe -n 1 %Address% | %SystemRoot%\system32\find.exe "TTL=" > NUL >> logfile.log

if %ERRORLEVEL% EQU 0 goto :Loop

echo Error Detected! >>logfile.log
echo Error Detected! 

echo Trace route %Address% at %date% %time% >> logfile.log
tracert %Address% >> logfile.log

echo .
echo . >> logfile.log

goto Loop
pause Somehow, I got out of the loop


Of course, you can ping another site besides Google, and you can test more or less frequently than 60 seconds.

The log file grows forever unless you rename it, and looks a lot like this:
Thu 09/21/2017 
15:55:28.70 
Error Detected! 
Trace route google.com at Thu 09/21/2017 15:55:40.74 
Unable to resolve target system name google.com.
. 
15:56:10.16 
Error Detected! 
Trace route google.com at Thu 09/21/2017 15:56:22.19 
Unable to resolve target system name google.com.
. 
15:56:52.15 
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54
15:57:22.17 
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54
15:57:52.13 
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54
15:58:22.11 
Reply from 172.217.4.142: bytes=32 time=17ms TTL=54
15:58:52.18 
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54



Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Share This!

Contact Us

Name

Email *

Message *