Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use batch processing to realize computer / Network equipment status Monitoring script

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use batch processing to achieve computer / network equipment status monitoring script", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use batch processing to achieve computer / network equipment status monitoring script" this article.

A monitoring script written by myself uses the PING command to check the IP in an IP list every 10 seconds. If it does not work, it is sent through a messenger message and an alarm sound is made using BEEP. Need a file sleep.exe (you can go to the next one online), BEEP.EXE (you can write it with DELPHI yourself, you don't need it, you can remove the code, or you can find one online), then create a file ip.txt,user.txt and run the script.

The 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-after the first round of inspection, if you do not hear the alarm sound, it means that all IP can communicate with PING.

Echo-if there is an abnormal IP, please manually use the PING command to confirm the correctness of the check-

Echo-now do a loop check, check one IP every other 10000ms

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-N1-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, one IP per line, and the name can be entered after the equal sign

192.168.0.1 = Group Gateway

192.168.0.123=test

User.txt, computer name or IP, send a message to the user in the text when the network is detected to be unavailable

Computername

The above is all the contents of the article "how to use batch processing to implement computer / network equipment status monitoring script". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report