Frage

I have a simple script that creates a serious of Perfmon counters then starts them.

For some reason any Processor Information counters in the script, the ones with CPU in the name, do not work. An output file is created but it contains only the datetime value, no actual counter values. However if I copy the line to the command window it will run successfully.

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
War es hilfreich?

Lösung

The problem was the % characters needed escaping. E.g. I replaced

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

with

"\Processor Information(*)\%% Processor Time"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top