Use batch ping ip to detect and record logs

       Because sometimes the network management equipment of the higher-level unit in the unit reports that the gateway is unreachable, but it is actually connected, and our Internet access is not affected. There are various reasons: the firewall detects the action of the network management device and automatically blocks it as an attack; We have not been notified and so on. In order to detect that the network status is not notified in time, I made a batch program, which has been running, and pings the upper-level server every 10 seconds, and records it in a text file to make a log.

       For eye-catching, the red background means that the ping fails, and the green background means that the ping IP is normal.

@echo off

:pingip
color %bf%
ping -4 -n 1 10.1.1.1
if %errorlevel%==0 goto OK
if %errorlevel%==1 goto NO
exit

:NO
set bf=c0
echo %date%_%time%_ping Timeout>>%date%
timeout /T 10 /nobreak
cls
goto pingip

:OK
set bf=a0
echo %date%_%time%_ping OK>>%date%
timeout /T 10 /nobreak
cls
goto pingip

       * Here you need to set the date format of the system to YYYY-MM-DD, otherwise the default slash in the date will be ambiguous with the system directory, resulting in an error that the system cannot find the directory

Guess you like

Origin blog.csdn.net/jiecy/article/details/130854917