Skip to main content

Cisco NX-OS interface slower than 1Gbps

Find all interface speeds slower than 1Gbps on Cisco NX-OS devices

The following query shows how to find information in nested config lines.

Using patternMatches

foreach device in network.devices
where device.platform.vendor == Vendor.CISCO &&
device.platform.os == OS.NXOS
foreach ifaceMatch in patternMatches(device.files.config, `interface {iface:string}`)
foreach speedMatch in patternMatches(ifaceMatch.line.children, `speed {speed:number}`)
select {
device: device.name,
iface: ifaceMatch.data.iface,
speed: speedMatch.data.speed,
violation: speedMatch.data.speed < 1000
}

Using patternMatch

foreach device in network.devices
where device.platform.vendor == Vendor.CISCO &&
device.platform.os == OS.NXOS
foreach line in device.files.config
let ifaceMatch = patternMatch(line.text, `interface {iface:string}`)
where isPresent(ifaceMatch)
foreach childLine in line.children
let speedMatch = patternMatch(childLine.text, `speed {speed:number}`)
where isPresent(speedMatch)
select {
device: device.name,
iface: ifaceMatch.iface,
speed: speedMatch.speed,
violation: speedMatch.speed < 1000
}