The NCM API gives remote access to a broad subset of functions and data that is ordinarily available to end users of the NCM Client UI. However, formatting and display based views of that data as presented in the Client UI are not always available. Serial numbers of device chassis for devices that participate in a stack under the same management IP address are an example of one instance where the data is not readily available through the API in the same, simple, list format that you can see in the Client UI. Stack sub component device chassis are currently only visible through the API as content encapsulated in configuration files pulled form the stack. Since stack component devices can change, it is considered subject to revision and those changes may be possible to track through the revision history for that device. If API access to that information is desired, it is currently necessary to parse the output of device configuration files to extract the data.
To obtain a list of stack sub component device chassis serial numbers for the latest revision of a given device from the NCM PostgreSQL Control Database for use in comparing to the Client UI data or data produced by external code that parses configuration file content for that data, you can do as follows:
su - pgdba -c 'psql voyencedb voyence'
%VOYENCE_HOME%\db\controldb\bin\psql -p 5435 -h 127.0.0.1 --username=voyence -d voyencedb
PREPARE current_stack_chassis_sn_list(int) AS SELECT h.element_name, h.description, h.serialnumber AS serial_number FROM cm_device d JOIN ( SELECT device_id, revision_id, max(revision_number) FROM cm_config_unit_revision GROUP BY device_id, revision_id ) AS r ON d.device_id = r.device_id JOIN dm_hw_element_view h ON r.revision_id = h.revision_id WHERE d.device_status = 'enum.deviceStatus.operational' AND d.is_operational_device IS TRUE AND element_name = 'Chassis' AND device_idx = $1;
voyencedb=# EXECUTE current_stack_chassis_sn_list(1003); element_name | description | serial_number --------------+---------------------------------------------------+--------------- Chassis | Cisco Catalyst 3750 (1 Slot) Chassis | CYS14190265 Chassis | Cisco EtherSwitch Service Module (2 Slot) Chassis | ESM00190266 Chassis | Cisco EtherSwitch Service Module (3 Slot) Chassis | ESM00190267 (3 rows) voyencedb=#