Perfmon计数器在脚本中不起作用

时间:2014-01-30 23:23:15

标签: scripting perfmon

我有一个简单的脚本,可以创建一个严重的Perfmon计数器然后启动它们。

由于某种原因,脚本中的任何处理器信息计数器,名称中具有CPU的计数器都不起作用。创建输出文件,但它仅包含日期时间值,不包含实际计数器值。但是,如果我将该行复制到命令窗口,它将成功运行。

echo Objective Reporting Data Extraction - %date% - %time%

REM Write output to this location
set OUTPUTDIR=PERFMON_CSV
mkdir %OUTPUTDIR%

REM Counter collection frequency
set PERIOD=00:00:05

REM Create some collectors to collect the Server Health Check perfmon stats

c:\Windows\System32\Logman.exe create counter Obj_HC_svr_memory_5sec -o "%OUTPUTDIR%\obj_HC_svr_Memory_5sec" -f csv -v mmddhhmm  -max 300 -c "\Memory\Available MBytes" "\Memory\Pages/sec" "\Memory\Page faults/sec" "\Memory\Free system page table entries" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter Obj_HC_svr_bytes_received_5sec -o "%OUTPUTDIR%\obj_HC_svr_bytes_received_5sec" -f csv -v mmddhhmm  -max 300 -c "\Network Interface(*)\Bytes Received/sec" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter Obj_HC_svr_bytes_sent_5sec -o "%OUTPUTDIR%\obj_HC_svr_bytes_sent_5sec" -f csv -v mmddhhmm  -max 300 -c "\Network Interface(*)\Bytes Sent/sec" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_Disk_queue_5sec -o "%OUTPUTDIR%\obj_HC_svr_Disk_queue_5sec" -f csv -v mmddhhmm  -max 300 -c "\PhysicalDisk(*)\Avg. Disk Queue Length" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_Disk_read_5sec -o "%OUTPUTDIR%\obj_HC_svr_Disk_read_5sec" -f csv -v mmddhhmm  -max 300 -c "\PhysicalDisk(*)\Avg. Disk sec/Read" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_disk_write_5sec -o "%OUTPUTDIR%\obj_HC_svr_disk_write_5sec" -f csv -v mmddhhmm  -max 300 -c "\PhysicalDisk(*)\Avg. Disk sec/Write" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_disk_bytes_5sec -o "%OUTPUTDIR%\obj_HC_svr_disk_bytes_5sec" -f csv -v mmddhhmm  -max 300 -c "\PhysicalDisk(*)\Disk Bytes/sec" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_disk_transfer_5sec -o "%OUTPUTDIR%\obj_HC_svr_disk_transfer_5sec" -f csv -v mmddhhmm  -max 300 -c "\PhysicalDisk(*)\Disk Transfers/sec" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_CPU_time_5sec -o "%OUTPUTDIR%\obj_HC_svr_CPU_time_5sec" -f csv -v mmddhhmm  -max 300 -c "\Processor Information(*)\% Processor Time" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_CPU_privileged_5sec -o "%OUTPUTDIR%\obj_HC_svr_CPU_privileged_5sec" -f csv -v mmddhhmm  -max 300 -c "\Processor Information(*)\% Privileged Time" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_CPU_idle_5sec -o "%OUTPUTDIR%\obj_HC_svr_CPU_idle_5sec" -f csv -v mmddhhmm  -max 300 -c "\Processor Information(*)\% Idle Time" -si %PERIOD%
c:\Windows\System32\Logman.exe create counter obj_HC_svr_Processor_5sec -o "%OUTPUTDIR%\obj_HC_svr_Processor_5sec" -f csv -v mmddhhmm  -max 300 -c "\System\Processor Queue Length" "\System\Context switches/sec" -si %PERIOD%


REM Now start them
c:\Windows\System32\Logman.exe start Obj_HC_svr_memory_5sec
c:\Windows\System32\Logman.exe start Obj_HC_svr_bytes_received_5sec
c:\Windows\System32\Logman.exe start Obj_HC_svr_bytes_sent_5sec
c:\Windows\System32\Logman.exe start obj_HC_svr_Disk_queue_5sec 
c:\Windows\System32\Logman.exe start obj_HC_svr_Disk_read_5sec
c:\Windows\System32\Logman.exe start obj_HC_svr_disk_write_5sec
c:\Windows\System32\Logman.exe start obj_HC_svr_disk_bytes_5sec
c:\Windows\System32\Logman.exe start obj_HC_svr_disk_transfer_5sec 
c:\Windows\System32\Logman.exe start obj_HC_svr_CPU_time_5sec
c:\Windows\System32\Logman.exe start obj_HC_svr_CPU_privileged_5sec
c:\Windows\System32\Logman.exe start obj_HC_svr_CPU_idle_5sec
c:\Windows\System32\Logman.exe start obj_HC_svr_Processor_5sec

1 个答案:

答案 0 :(得分:0)

问题是需要转义的%字符。例如。我换了

"\Processor Information(*)\% Processor Time"

"\Processor Information(*)\%% Processor Time"