This example describes how to determine the empty slots available for new memory cards. This information is useful to system administrators who want to upgrade the capacity of a managed server.

This example shows how to locate information about the installed memory and available slots by using only the objects in the Implementation namespace. Locating Physical Memory Slots shows the CIM objects involved.

You can locate used memory slots by enumerating physical memory instances. To locate unused slots, you also enumerate the OMC_MemorySlot instances and compare the results. The set of unused slots comprises all those OMC_MemorySlot instances whose ElementName property does not match any of the instances of OMC_PhysicalMemory.

Note:

This example assumes that the managed server is a single-node system.

Figure 1. Locating Physical Memory Slots
Diagram shows classes used to locate empty memory slots.

This pseudocode depends on the pseudocode in Make a Connection to the CIMOM.

To report empty memory slots

This pseudocode depends on the pseudocode in Make a Connection to the CIMOM and Identifying the Base Server Scoping Instance.

To report CPU cores and threads

Procedure

  1. 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 implementation.

    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)
  2. Enumerate the OMC_PhysicalMemory instances.
    chip_instances = connection.EnumerateInstances( ’OMC_PhysicalMemory’ )
    if len( chip_instances ) is 0
       print 'Error:  No physical memory instances were found.'
       sys.exit(-1)
  3. Enumerate the OMC_MemorySlot instances.
    slot_instances = connection.EnumerateInstances( ’OMC_MemorySlot’ )
    if len( slot_instances ) is 0
       print 'Error:  No memory slot instances were found.'
       sys.exit(-1)
  4. For each OMC_MemorySlot instance, compare the ElementName property with the set of OMC_PhysicalMemory instances, and discard the instances that have matching ElementName properties.

    For other instances, print the ElementName property.

    function slot_filled( slot, chips )
       for chip in chips
          if slot['ElementName'] == chip['ElementName']
             return True
       return False
    
    empty_slots = []
    for slot_instance in slot_instances
       if not slot_filled( slot_instance, chip_instances )
          empty_slots.append( slot_instance )
    print '  %s empty memory slots found.' % len( empty_slots )
    for slot_instance in empty_slots
       print slot_instance['ElementName']

    A sample of the output looks like the following:

      4 empty memory slots found.
    DIMM 3C
    DIMM 4D
    DIMM 7C
    DIMM 8D