gulden has asked for the wisdom of the Perl Monks concerning the following question:
I'm always getting the same values they don't change...my $class = "Win32_PerfFormattedData_PerfOS_Processor"; my $key = 'Name'; # CORRECTION: user feedback BrowserUK my @properties = qw(PercentIdleTime PercentProcessorTime PercentPr +ivilegedTime PercentUserTime PercentInterruptTime); my $wmi = Win32::OLE->GetObject("winmgmts://./root/cimv2") or die "Failed getobject\n"; my $list, my $v; $list = $wmi->InstancesOf("$class") or die "Failed getobject\n"; foreach $v (in $list) { $hash->{$v->{$key}}->{$_} = $v->{$_} for @properties; } print Dumper $hash;
Here's the output:
What am i doing wrong?$VAR1 = { '0' => { 'PercentPrivilegedTime' => '0', 'PercentIdleTime' => '0', 'PercentInterruptTime' => '0', 'PercentUserTime' => '0', 'PercentProcessorTime' => '100' }, '_Total' => { 'PercentPrivilegedTime' => '0', 'PercentIdleTime' => '0', 'PercentInterruptTime' => '0', 'PercentUserTime' => '0', 'PercentProcessorTime' => '100' } };
Tks in advance,
gulden
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to GET CPU values from WMI
by BrowserUk (Patriarch) on Jan 20, 2011 at 16:00 UTC | |
by gulden (Monk) on Jan 20, 2011 at 16:39 UTC | |
by BrowserUk (Patriarch) on Jan 20, 2011 at 18:34 UTC | |
|
Re: How to GET CPU values from WMI
by gulden (Monk) on Jan 20, 2011 at 17:01 UTC | |
|
Re: How to GET CPU values from WMI
by gulden (Monk) on Mar 10, 2011 at 14:07 UTC |