Hi,
I have found a machine here that had 4 CPUs with Hyperthreading but we
took one out (to save one SQL Server license), your script gave out 4
real processors.  I found one virtual CPU with CpuSocketDesignation =
'Proc 4' but the CpuStatus is set 0.  I just added a test to be
sure we count only CPUs with CpuStatus>0.

Here is the modified scritp:
--------------------------------------------------------------------------------
use strict;
use Win32::OLE qw( in );
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my $server = shift @ARGV || ".";
my $objWMIService =
Win32::OLE->GetObject("winmgmts:\\\\$server\\root\\CIMV2") or die "WMI
connection failed.\n";
my $Processors = $objWMIService->InstancesOf("Win32_Processor");
my %sockets = ( );

foreach my $CPU (in $Processors)
{
 print "CPU Name: " . $CPU->{Name}."\n";
 print "CPU Socket: ".$CPU->{SocketDesignation}."\n";
 print "Cpu Status: ".$CPU->{CpuStatus}."\n";
 if ($CPU->{CpuStatus}>0) {$sockets{$CPU->{SocketDesignation}}=1}
 }
print "True processor count: ".scalar(keys %sockets)."\n";
exit;
------------------------------------------------------------------------------

With this very little modification it seems to give a perfect score on
most of our servers.

??? I'm not anymore sure about this since I have found out that the CpuStatus seems to be 0 for a Dual Core processor...GRRR!

Regards,

     BT


==============================================================================
On Tue, 28 Feb 2006 2:10 PM "Steven Manross" <[EMAIL PROTECTED]> wrote:

This one is a little bit amusing...  But...

If you look at the "SocketDesignation" HT processors seem to all have a
SocketDesignation identical to the first processor.  This was also
discussed on google groups a few months back where there's a test VB
script to show the same thing.

So, if you have 2 CPUs...

And say (listings from WMI)
CPU 1 SocketDesignation=1
CPU 2 SocketDesignation=1
CPU 3 SocketDesignation=2 CPU 4 SocketDesignation=1

CPU 2 and 4 are hyperthreaded..  1 and 3 are real...  But you really
just want to count the unique "SocketDesignation"s.. to get your true
processor count.

I've been warned not to trust this too readily as it may not be true
across all platforms with good reason -- subject to change, etc, but
from my limited testing on Proliant servers DL380G1 - DL380G4 Servers,
Dell Clients, HP Kayak P3 (non-HT -- multi processor boxes) and others,
it seems to work pretty well.  Your mileage may vary.

Here's a perl-converted reprint of that script..

Steven
---------------------

use Win32::OLE qw (in);

$server = "SERVER";
$Processors =
Win32::OLE->GetObject("winmgmts://".$server)->InstancesOf("Win32_Process
or");

foreach $CPU (in $Processors) {
 print "CPU Name: " . $CPU->{Name}."\n";
 print "CPU Socket: " . $CPU->{SocketDesignation}."\n";
 $sockets{$CPU->{SocketDesignation}}=1;
}

print "True processor count: ".scalar(keys %sockets)."\n";



_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to