window server 2003 创建性能计数器bat脚本

文件名:perfmon_创建性能计数器.bat 

这是原来使用window server 2003 操作系统时采集服务器性能数据写的一个小脚本。

@echo off

mkdir E:\perflogs
rem 第二次执行是开启del
rem del %tmp%\temp1.txt
cacls E:\perflogs /e /c /g "Performance Log Users":F
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=2 delims=:" %%i in ('ipconfig /all%^| findstr "Description"') do (
          set netcard=%%i
          set netcard=!netcard:~1,-1!
          echo !netcard!>>%tmp%\temp1.txt
          findstr /n ".*" %tmp%\temp1.txt>%tmp%\temp2.txt
)
    
for /f "tokens=1,* delims=:" %%j in ('findstr "1:" %tmp%\temp2.txt') do (
set tmpvar=%%k
set tmpvar=!tmpvar:(=[!
set tmpvar=!tmpvar:^)=]!
        set tmpvar=!tmpvar:^/=_!
set tmpvar=!tmpvar:#=!
        set tmpvar=!tmpvar:#=_!
set cardnameone=!tmpvar!
 )
 
for /f "tokens=1,* delims=:" %%l in ('findstr "2:" %tmp%\temp2.txt') do (
        set tmpvar=%%m
set tmpvar=!tmpvar:(=[!
set tmpvar=!tmpvar:^)=]!
        set tmpvar=!tmpvar:^/=_!
set tmpvar=!tmpvar:#=_!
        set cardnametwo=!tmpvar!
 )
 
for /f %%n in ('hostname') do set HN=%%n
Logman create counter dailya_perf_log -o  "e:\perflogs\daily_log" -v mmddhhmm -f csv -c "\\!HN!\Processor(_Total)\%% Processor Time" "\\!HN!\Memory\Available Mbytes" "\\!HN!\Memory\%% Committed Bytes In Use" "\\!HN!\PhysicalDisk(_Total)\Avg. Disk Bytes/Read" "\\!HN!\PhysicalDisk(_Total)\Avg. Disk Bytes/Write" "\\!HN!\PhysicalDisk(_Total)\Disk Bytes/sec" "\\!HN!\PhysicalDisk(_Total)\Avg. Disk Queue Length" "\\!HN!\PhysicalDisk(_Total)\Current Disk Queue Length" "\\!HN!\PhysicalDisk(_Total)\Split IO/Sec" 
rem 开始:logman start 性能计数器名称
rem 结束:logman stop 性能计数器名称
pause