Taking an inventory of systems in your datacenter can be a first step to monitoring the status of the servers. You can store the inventory data for future use when you monitor configuration changes.
This example shows how to get physical identifying information from the Interop namespace by traversing associations to the CIM_Chassis for the Scoping Instance. Locating Chassis Information from the Base Server Scoping Instance shows the relationships of the CIM objects involved.
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 Scoping Instance.'
sys.exit(-1)
Traverse the CIM_ComputerSystemPackage association to reach the CIM_Chassis instance that corresponds to the managed server.
instance_names = connection.AssociatorNames( scoping_instance_name, \
AssocClass = 'CIM_ComputerSystemPackage', \
ResultClass = 'CIM_Chassis' )
if len( instance_names ) > 1
print 'Error: %d Chassis instances found for Scoping Instance.' \
% len ( instance_names )
sys.exit(-1)
Print the Manufacturer, Model, and SerialNumber properties.
This example prints additional properties to help identify physical components.
instance_name = instance_names.pop()
instance = connection.GetInstance( instance_name )
print ’\n’ + ’CIM_Chassis [’ + instance.classname + ’] =’
for property_name in [ ’ElementName’, ’Tag’, \
’Manufacturer’, ’Model’, ’SerialNumber’ ]
if instance.key( property_name )
value = instance[ property_name ]
else
value = ’(not available)’
print ’ %30s : %s’ % ( property_name, value )
A sample of the output looks like the following:
CIM_Chassis [OMC_Chassis] =
ElementName : Chassis
Tag : 23.0
Manufacturer : Cirrostratus Systems
Model : 20KF6KM
SerialNumber : 67940851