In the past, I wrote a monitoring script to check the IP addresses in an IP list every 10 seconds by using the PING command. If the IP addresses in an IP list cannot be accessed, send messages via the messenger message and use BEEP to send alarms. Run the script.
Copy codeThe Code is as follows: rem main. bat
@ Echo off
For/F "eol =; tokens = 1, 2 * delims =" % I in (ip. TXT) do call: checkip % I % j 0
Echo --------------------------------------------------------------
Echo ---- the first round of check is complete. If no alarm is reported, all IP addresses can be pinged ----
Echo ---- if an abnormal IP address exists, run the PING command to verify the correctness of the check ----
Echo ---- perform cyclic check now and check an IP address every other MS ----
Echo --------------------------------------------------------------
: Begin
For/F "eol =; tokens = 1, 2 * delims =" % I in (ip. TXT) do call: checkip % I % j 10000
Goto begin
: Checkip
@ Echo off
PING % 1-n 1 | FIND "TTL ="> NUL
If not errorlevel 1 ECHO % 1 (% 2) Status OK at % TIME %
If not errorlevel 1 GOTO NEXT
PING % 1-n 1-w 3000 | FIND "TTL ="> NUL
If % ERRORLEVEL % = 1 call: send % 1% 2 else echo % 1 (% 2) Status OK at % TIME %
: Next
Sleep % 3
Goto end
: Send
@ Echo off
ECHO % 1 (% 2): Status ERROR at % TIME % :::::
For/F "eol =;" % I in (user. TXT) do net send % I "Error Pinging % 1 (% 2)."> NUL
Beep 1500 500
Beep 500 500
Beep 1500 500
Beep 500 500
Goto end
: End
;Ip.txt, key IP address, one IP address per line. You can enter a name after the equal sign.
192.168.0.1 = group Gateway
192.168.0.123 = test
When the computer name or IP address detects that the network is disconnected, send a message to the user in the text.
Computername