国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > BAT > 正文

批處理實現的網絡巡檢腳本(PING與端口掃描)

2020-06-09 14:20:15
字體:
來源:轉載
供稿:網友
check.bat 內容(腳本內容可能會應為排版問題不能直接復制粘帖運行,可自行修改):
復制代碼 代碼如下:

@echo off
rem checklist.csv字段為: IP,名稱,描述,TCP應用端口,UDP應用端口
rem checklist.csv中請使用,@,替換,, 并不要使用()進行內容描述
set e_file=error.log
set e_count=0
for /f "skip=1 tokens=1,2,3,4,5* delims=," %%i in (checklist.csv) do call :docheck %%i @%%j @%%k @%%l @%%m
call :report
goto :eof
:docheck
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 300 >nul 2>&1
if NOT %ERRORLEVEL%==0 (echo %time% %ip%[%name%,%comment%] ping error >>%e_file% & set /a e_count=%e_count%+1) else call :portcheck
call :report
goto :eof
:portcheck
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
:report
echo %e_count%
rem do whatever you want. such as send error.log by mail
goto :eof

checklist.csv樣例:
IP,名稱,描述,TCP應用端口,UDP應用端口 '兩個逗號之間要加入@,描述不能加入括號(),請用[]替代
192.168.0.1,@,@,@,
192.168.0.3,@,@,@,
192.168.0.9,FTPSERVER,FTP服務器,135-445-21,
192.168.0.10,TESTSERVER,TESTSERVER,135-445-21,53
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 饶平县| 大洼县| 青川县| 毕节市| 祁门县| 泽州县| 宜宾市| 安福县| 西林县| 东港市| 金华市| 汝城县| 临武县| 桦南县| 巴林左旗| 怀宁县| 大邑县| 景德镇市| 阿城市| 新乐市| 海口市| 大田县| 绥江县| 大同市| 团风县| 富锦市| 临海市| 年辖:市辖区| 盱眙县| 汕头市| 娱乐| 乌什县| 陵水| 福贡县| 遂宁市| 晋城| 宁阳县| 奎屯市| 墨脱县| 柏乡县| 凤台县|