This information is useful to system administrators who need to monitor system health. This example shows how to enumerate the processor cores and hardware threads in a managed server.
The VMware implementation does not include instances of CIM_ProcessorCapabilities, but cores and hardware threads are modeled with individual instances of CIM_ProcessorCore and CIM_HardwareThread.
This example shows how to locate information about the CPU cores and threads by starting from the Interop namespace and traversing associations from the managed server Scoping Instance. A managed server has one or more processors, each of which has one or more cores with one or more threads. Locating CPU Cores and Hardware Threads shows the relationships of the CIM objects involved. For simplicity, the diagram shows only a single processor with one core and one hardware thread.
Specify the Interop namespace, supplied as a parameter, for the connection.
use wbemlib
use sys
use connection renamed cnx
connection = Null
params = cnx.get_params()
if params is Null
sys.exit(-1)
interop_params = params
interop_params['namespace'] = 'root/interop'
connection = cnx.connect_to_host( interop_params )
if connection is Null
print 'Failed to connect to: ' + params['host'] + ' as user: ' + params['user']
sys.exit(-1)
Locate the Base Server Scoping Instance of CIM_ComputerSystem.
use scoping_instance renamed si
scoping_instance_name = si.get_scoping_instance_name( connection )
if scoping_instance_name is Null
print 'Failed to find server Scoping Instance.'
sys.exit(-1)
Traverse the CIM_SystemDevice association to reach the CIM_Processor instances on the managed server.
proc_instance_names = connection.AssociatorNames( scoping_instance_name, \
AssocClass = 'CIM_SystemDevice', \
ResultClass = ’CIM_Processor’ )
if len( proc_instance_names ) is 0
print 'Error: No processors associated with server Scoping Instance.'
sys.exit(-1)
For each CIM_Processor instance, print the ElementName, Family, and CurrentClockSpeed properties.