Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get data from performance counters only for one particular process

8 views
Skip to first unread message

stej

unread,
Nov 19, 2009, 7:50:49 AM11/19/09
to
Look at this:

[30]: Get-Process svchost

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
260 13 6088 10408 67 1,87 248 svchost
759 43 12540 15400 112 3,95 684 svchost
708 39 21840 17420 150 9,22 768 svchost
...
94 8 2680 4552 50 0,16 2324 svchost

[31]: Get-Counter -list process -computer c | select -exp
pathswithinstances | ? { $_ -match 'svchost' }
\\c\Process(svchost)\% Processor Time
\\c\Process(svchost)\% Processor Time
....
\\c\Process(svchost)\% Processor Time
\\c\Process(svchost)\% User Time
....


count of % Processor Time is the same as count of svchost processes.
When I want counters related to svchost-s, I get only one sample!

[32]: Get-Counter 'Process(svchost)\% Processor Time' -ComputerName
devol

Timestamp CounterSamples
--------- --------------
19.11.2009 13:48:08 \\c\process(svchost)\% processor time :
0

First question - why I get only one sample for [32] command?
Second - how do I get samples only for svchost with Id 12345? It's
pretty useless when you don't know how to query one particular
process :(

Marco Shaw [MVP]

unread,
Nov 19, 2009, 12:13:33 PM11/19/09
to
> First question - why I get only one sample for [32] command?

If you check "help get-counter", you can specify these parameters to get
more than one value:

[-MaxSamples <Int64>]
[-SampleInterval <int>]

> Second - how do I get samples only for svchost with Id 12345? It's
> pretty useless when you don't know how to query one particular
> process :(

That's a good question. I don't know if you'll be able to use Get-Counter
if you need a specific ID...

Marco

stej

unread,
Nov 19, 2009, 3:46:57 PM11/19/09
to
Thank you. I misinterpreted -MaxSamples. I'll look at it again.

To the second question - I need to get samples for one particular
svchost, it doesn't matter how the proc is identified. I just see the
process in ProcessExplorer and I need to get its counters in
PowerShell. It seems impossible.

On 19 lis, 18:13, "Marco Shaw [MVP]" <marco.shaw@NO_SPAMgmail.com>
wrote:

Marco Shaw [MVP]

unread,
Nov 19, 2009, 7:35:15 PM11/19/09
to
> To the second question - I need to get samples for one particular
> svchost, it doesn't matter how the proc is identified. I just see the
> process in ProcessExplorer and I need to get its counters in
> PowerShell. It seems impossible.

I'll the more raw .NET method maybe tomorrow...

Marco

0 new messages