Skip to main content

Hello Team, we have an NQE that

  1. searches all L2 switches
  2. obtains each interface status
  3. obtains speed
  4. obtains sfp information

for all ports in up state. So far, we have the following:

foreach device in network.devices
foreach item in device.platform.components
where item.partType == DevicePartType.TRANSCEIVER

let interface = (foreach interface in device.interfaces
where isPresent(findInterface(device, item.name))
where interface.name == findInterface(device, item.name).interface.name
select interface)
where length(interface) == 1
let int = min(interface)
select {
deviceName: device.name,
iface: int.name,
speed: int.ethernet.negotiatedPortSpeed,
partType: item.partType,
partName: item.name,
}

 

Is there a way we could extract and add the below underlined in BLUE as additional columns as well? 

 

Thanks in advance for your time and help

Cisco is not consistent about whether it represents the transceivers in the “show inventory”.  If that info is included as the PID (Part ID) then you can use the data model entry of device.platform.component.partId. Which in your query would be “item.partId”.  You would need to write it as “item?.partId”.  The “?.” will make it so this line of the query will not through an error if the data is “null”.

If that media type is not included as the “partId”, then you will need to parse one of the show commands to get the data.


Reply