Check.bat content (script content may be due to typesetting problems can not be directly copied paste run, can be modified):
Copy Code code as follows:
@echo off
rem checklist.csv field: IP, Name, description, TCP application port, UDP application port
In rem checklist.csv, use, @, replace, and do not use () for content description
Set E_file=error.log
Set e_count=0
for/f "Skip=1 tokens=1,2,3,4,5* delims=,%%i in (checklist.csv) does call:d Ocheck%%i @%%j @%%k @%%l
Call:report
Goto:eof
:d Ocheck
Set ip=%1
Set name=%2
Set name=%name:@=%
Set comment=%3
Set comment=%comment:@=%
Set tcp=%4
Set tcp=%tcp:@=%
Set udp=%5
Set udp=%udp:@=%
Ping%ip%-n 3-w >nul 2>&1
If not%errorlevel%==0 (Echo%time%%ip%[%name%,%comment%] Ping error >>%e_file% & set/a e_count=%e_count%+1) E LSE Call:P Ortcheck
Call:report
Goto:eof
:p Ortcheck
If not-%tcp%==-for/f ' tokens=1,2,3,4,5,6,7,8,9,10* delims=-'%%i in ('%tcp% ') do call:tcpcheck%%i%%j%%k%%l%%m%%n %%o%%p%%q
If not-%udp%==-for/f ' tokens=1,2,3,4,5,6,7,8,9,10* delims=-'%%i in ('%udp% ') do call:udpcheck%%i%%j%%k%%l%%m%%n %%o%%p%%q
Goto:eof
: Tcpcheck
If not-%1==-call:tcpquery%1
If not-%2==-call:tcpquery%2
If not-%3==-call:tcpquery%3
If not-%4==-call:tcpquery%4
If not-%5==-call:tcpquery%5
If not-%6==-call:tcpquery%6
If not-%7==-call:tcpquery%7
If not-%8==-call:tcpquery%8
If not-%9==-call:tcpquery%9
Goto:eof
: Udpcheck
If not-%1==-call:udpquery%1
If not-%2==-call:udpquery%2
If not-%3==-call:udpquery%3
If not-%4==-call:udpquery%4
If not-%5==-call:udpquery%5
If not-%6==-call:udpquery%6
If not-%7==-call:udpquery%7
If not-%8==-call:udpquery%8
If not-%9==-call:udpquery%9
Goto:eof
: Tcpquery
Portqry-n%ip%-e%1-p tcp | | (Echo%time%%ip%[%name%,%comment%] TCP port%1 query error >>%e_file% & set/a e_count=%e_count%+1)
Goto:eof
: Udpquery
Portqry-n%ip%-e%1-p UDP | | (Echo%time%%ip%[%name%,%comment%] UDP port%1 query error >>%e_file% & set/a e_count=%e_count%+1)
Goto:eof
: the
Echo%e_count%
REM do whatever your want. such as Send error.log by mail
Goto:eof
Checklist.csv Sample:
IP, Name, description, TCP application port, UDP application Port ' two comma to join @, description can not add parentheses (), please replace
192.168.0.1,@,@,@,
192.168.0.3,@,@,@,
192.168.0.9,ftpserver,ftp Server, 135-445-21,
192.168.0.10,testserver,testserver,135-445-21,53