Retrieve Performance Counter value with exec metric

287 views
Skip to first unread message

hoeks...@gmail.com

unread,
Nov 21, 2012, 5:13:18 AM11/21/12
to jmeter-...@googlegroups.com
I'm trying retrieve the value of a windows performance counter by putting the following command in an exec metric in the metrics collector. For example by doing the following:

powershell.exe:(Get-Counter -Counter '\Processor(_Total)\% Processor Time' -MaxSamples 1).CounterSamples[0].CookedValue

The line will return a single numerical value. The JMeter agent just hangs when I execute the test plan. It does not give me any errors so that makes me think that there is not a lot wrong with the command itself. It does take 1 or 2 seconds to retrieve the value so maybe that is an issue. How long will the metric collector wait for a response on an executed command? 

Andrey Pohilko

unread,
Nov 25, 2012, 8:48:23 AM11/25/12
to jmeter-...@googlegroups.com, hoeks...@gmail.com
remember that you should escape colon sign (:) with backslash in perfmon parameters.

Works it then?

среда, 21 ноября 2012 г., 14:13:18 UTC+4 пользователь hoeks...@gmail.com написал:

hoeks...@gmail.com

unread,
Nov 25, 2012, 1:09:28 PM11/25/12
to jmeter-...@googlegroups.com, hoeks...@gmail.com
Well the command I'm trying to run is powershell.exe (Get-Counter -Counter '\Processor(_Total)\% Processor Time' -MaxSamples 1).CounterSamples[0].CookedValue. I'm already seperating the program to execute and the parameter with the colon so I believe the colon should not be escaped. When I run the escaped version it will throw an exception which is what i'd expect.

ERROR   2012-11-25 19:07:34.137 [kg.apc.p] (): Problems executing: powershell.exe:(Get-Counter -Counter '\Processor(_Total)\% Processor Time' -MaxSamples 1).CounterSamples[0].CookedValue
java.io.IOException: Cannot run program "powershell.exe:(Get-Counter -Counter '\Processor(_Total)\% Processor Time' -MaxSamples 1).CounterSamples[0].CookedValue": CreateProcess error=2, 
The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at kg.apc.perfmon.metrics.ExecMetric.getValue(ExecMetric.java:31)
        at kg.apc.perfmon.PerfMonMetricGetter.getMetricsLine(PerfMonMetricGetter
.java:114)
        at kg.apc.perfmon.PerfMonWorker.sendToUDP(PerfMonWorker.java:309)
        at kg.apc.perfmon.PerfMonWorker.processSenders(PerfMonWorker.java:277)
        at kg.apc.perfmon.PerfMonWorker.run(PerfMonWorker.java:243)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find th
e file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 9 more

hoeks...@gmail.com

unread,
Nov 25, 2012, 1:12:53 PM11/25/12
to jmeter-...@googlegroups.com, hoeks...@gmail.com
Hmm. When I run the original command I posted with jmeter 2.7 and perfmon plugins 0.5.4 it runs and hangs. With jmeter 2.8 and perfmon plugins 0.5.5 it runs and returns a value that is shown in the graph. Time for some updates.
Reply all
Reply to author
Forward
0 new messages