Habt ihr noch eine Idee, wie ich unter WindowsXP, 2000 und 2003 die Anzahl der CPUs per WMI bestimmen kann?
Spoiler anzeigen
#include <Array.au3>
$ip = "localhost"
$objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $ip & "\root\cimv2")
[/autoit] [autoit][/autoit] [autoit]MsgBox(0, "Anzahl CPUs", CPU_Sockets($ip))
[/autoit] [autoit][/autoit] [autoit]Func CPU_Sockets($srv)
Local $name, $colItems, $colItem, $ping, $socket, $i, $x, $j, $unique
$ping = Ping($srv)
If $ping Then
$colItems = $objWMIService.ExecQuery("Select SocketDesignation from Win32_Processor", "WQL", 0x30)
If IsObj($colItems) Then
For $objItem In $colItems
$socket &= $objItem.SocketDesignation & ";"
$i += 1
Next
$x = StringSplit(StringMid($socket, 1, StringLen($socket) - 1), ";", 2)
$unique = _ArrayUnique($x)
$j = $i / $unique[0]
SetError(0)
Return $i
Else
SetError(1)
Return "Error!"
EndIf
Else
SetError(1)
Return "Host not reachable"
EndIf
EndFunc
Meine Idee war es, die eindeutigen SocketDesignation zu zählen und durch die Anzahl der logischen CPUs zu teilen, leider funzt das Ganze nicht immer, da trotz einer CPU die Anzahl der verschiedenen SocketDesignation > 1 ist!
Z.B. auf einem Server mit einer CPU: Intel(R) Xeon(TM) Processor 2.666 GHz (x86 Family 6 Model 7 Stepping 6 -> 4 Cores) werden 2 verschiedene SocketDesignation zurückgegeben und somit ist die Rechnung falsch => 4:2 = 2
Ab Vista+ gibt es unter Win32_Processor NumberOfCores und NumberOfLogicalProcessors!
Ich möchte bei WMI bleiben, da ich Server Remote abfragen will!
Gruß,
UEZ