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 in monitoring configuration changes.
This example shows how to get the physical identifying information from the Implementation namespace by enumerating CIM_Chassis for the managed server. This approach is convenient when the namespace is known in advance. For information about getting physical identifying information by using the Interop namespace, see Report Manufacturer, Model, and Serial Number.
You might see more than one instance of CIM_Chassis if the managed server is a blade system. Locating Chassis Information in a Blade Server shows an example of a server with two instances of CIM_Chassis, one for a blade and the other for the blade enclosure.
To report Manufacturer, Model, and Serial Number by using only the Implementation namespace
Procedure
Connect to the server URL.
Specify the Implementation namespace, supplied as a parameter, for the connection.
The actual namespace you will use depends on your installation.
use wbemlib
use sys
use connection renamed cnx
connection = Null
params = cnx.get_params()
if params is Null
sys.exit(-1)
connection = cnx.connect_to_host( params )
if connection is Null
print 'Failed to connect to: ' + params['host'] + ' as user: ' + params['user']
sys.exit(-1)
Use the EnumerateInstances method to get all the CIM_Chassis instances on the server.
chassis_instance_names = connection.EnumerateInstanceNames( 'CIM_Chassis' )
if len( chassis_instance_names ) is 0
print 'No %s instances were found.' % ('CIM_Chassis')
sys.exit(0)
Print the Manufacturer, Model, and SerialNumber properties of the Chassis instances.
This example prints additional properties to help identify physical components.
use value_mapper renamed mapper
for instance_name in chassis_instance_names
print_chassis( connection, instance_name )
function print_chassis( connection, instance_name )
instance = connection.GetInstance( instance_name )
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 )
for property_name in [ ’PackageType’, 'ChassisPackageType' ]
if instance.key( property_name )
value = mapper.map_instance_property_to_string( connection,
instance,
property_name )
if value is Null
value = ’’
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-02
SerialNumber : 67940851
PackageType : Blade
ChassisPackageType : None
CIM_Chassis [OMC_Chassis] =
ElementName : Chassis
Tag : 23.1
Manufacturer : Cirrostratus Systems
Model : 20KF6KM-W
SerialNumber : 439-41902
PackageType : Chassis/Frame
ChassisPackageType : Blade Enclosure