下面是多方修改我最终要使用的脚本。之前没注意统计电话时出现的问题,后来自己摸索又请教他人以解决。
现在还有一点小要求,怎么能运行时生成5个dos监控窗口,而不是在一个窗口里展示,因为在一个窗口时间长了监控不方便,还得去打开txt查看。
因为事赶的紧,自己没太多时间来深入学习了,如果有哪位大师看到这,烦请给点提示。谢谢!!!- @echo off &color 0a &setlocal enabledelayedexpansion
- pushd "%cd%"
- rem 设置变量
- set Tm=300
- :main
- rem 初始化统计次数,每次循环都初始化,如果不需要,就放在 :main 标记前面
- set /a "a=b=c=d=e=f=g=h=i=j=0"
- rem 生成资源文件
- sures sures >sures.txt
- if not exist sures.txt (msg %username% /time:5 "错误!!未找到 sures.txt 文件!!!" &call exit)
- rem 生成agent资源使用情况统计文件
- if not exist "agent.txt" (echo.日期 时间 机器名 Agent使用数量/Agent空余数量)>"%computername%_agent.txt"
- for /f "delims=" %%a in ('findstr /i /c:"_12 RES IN USE" "sures.txt" 2^>nul') do (set /a "a+=1")
- for /f "delims=" %%a in ('findstr /i /c:"_12 RES AVAILABLE" "sures.txt" 2^>nul') do (set /a "b+=1")
- (echo.!date! !time! %computername% !a!^/!b!)>>"%computername%_agent.txt"
- type "%computername%_agent.txt"
- rem 生成电话资源使用情况统计文件
- if not exist "telephony.txt" (echo.日期 时间 机器名 电话使用数量/电话空余数量)>"%computername%_telephony.txt"
- for /f "delims=" %%a in ('findstr /rc:"INLINE.*_8 RES IN USE" "sures.txt" 2^>nul') do (set /a "c+=1")
- for /f "delims=" %%a in ('findstr /rc:"INLINE.*_8 RES AVAILABLE" "sures.txt" 2^>nul') do (set /a "d+=1")
- (echo.!date! !time! %computername% !c!^/!d!)>>"%computername%_telephony.txt"
- type "%computername%_telephony.txt"
- rem 生成动态库使用情况统计文件
- if not exist "ntdll.txt" (echo.日期 时间 机器名 动态库使用数量/动态库空余数量)>"%computername%_ntdll.txt"
- for /f "delims=" %%a in ('findstr /i /c:"_15 RES IN USE" "sures.txt" 2^>nul') do (set /a "e+=1")
- for /f "delims=" %%a in ('findstr /i /c:"_15 RES AVAILABLE" "sures.txt" 2^>nul') do (set /a "f+=1")
- (echo.!date! !time! %computername% !e!^/!f!)>>"%computername%_Ntdll.txt"
- type "%computername%_ntdll.txt"
- rem 生成数据库使用情况统计文件
- if not exist "database.txt" (echo.日期 时间 机器名 数据库使用数量/数据库空余数量)>"%computername%_database.txt"
- for /f "delims=" %%a in ('findstr /i /c:"_4 RES IN USE" "sures.txt" 2^>nul') do (set /a "g+=1")
- for /f "delims=" %%a in ('findstr /i /c:"_4 RES AVAILABLE" "sures.txt" 2^>nul') do (set /a "h+=1")
- (echo.!date! !time! %computername% !g!^/!h!)>>"%computername%_database.txt"
- type "%computername%_database.txt"
- rem 生成SOAP使用情况统计文件
- if not exist "soap.txt" (echo.日期 时间 机器名 SOAP使用数量/SOAP空余数量)>"%computername%_soap.txt"
- for /f "delims=" %%a in ('findstr /i /c:"_50 RES IN USE" "sures.txt" 2^>nul') do (set /a "i+=1")
- for /f "delims=" %%a in ('findstr /i /c:"_50 RES AVAILABLE" "sures.txt" 2^>nul') do (set /a "j+=1")
- (echo.!date! !time! %computername% !i!^/!j!)>>"%computername%_soap.txt"
- type "%computername%_soap.txt"
- ping localhost -n %TM% >nul
- cls &goto :main
复制代码
|