Computer/Network Equipment State Monitoring Script batch processing _dos/bat

Source: Internet
Author: User
Tags eol goto net send
Previously wrote a monitoring script, every 10 seconds using ping to check an IP list of IP, if not, then sent through Messenger message, and the use of beep issued an alarm sound. File Sleep.exe is required (available next to the Web), BEEP. EXE (Oneself with Delphi write, not necessary, the code can be removed, also can go to the Internet to find a), and then set up file Ip.txt,user.txt, run the script can.

Copy Code code 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 inspection completed, if not heard the alarm, the IP can be ping----
echo----If you have an abnormal IP, manually use the ping command again to confirm the correctness of the check----
echo----Now do a loop check and check an IP every 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-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, one line IP, followed by enter name
192.168.0.1= Group Gateway
192.168.0.123=test

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.