Join me for a look at the comparisons you can use in NQE to filter out on what data you need to see in your query.
Code examples used in video
Using equals (==
) to return any default routes in any VRF
foreach device in network.devices
foreach networkInstance in device.networkInstances
let afts = networkInstance.afts
let ipv4Unicast = afts.ipv4Unicast
foreach ipEntry in ipv4Unicast.ipEntries
where ipEntry.prefix == ipSubnet("0.0.0.0/0")
foreach nh in ipEntry.nextHops
where isPresent(nh.ipAddress)
select {
deviceName: device.name,
vrfName: networkInstance.name,
RouteEntry: ipEntry.prefix,
nextHop: nh.ipAddress
}
Using not equal to (!=
), to exclude ASA’s a platform inventory report
foreach device in network.devices
where device.platform.model != "ASAv"
select {
deviceName: device.name,
deviceModel: device.platform.model
}
Choose whether or not to report on interface MTU that is:
- Greater than 1500 (
>
) - Greater than or equal to 1500 (
>=
) - Less than 1500 (
<
) - Less than or equal to 1500 (
<=
)
foreach device in network.devices
foreach interface in device.interfaces
// where interface.mtu > 1500 // Greater than 1500
// where interface.mtu >= 1500 // Greater than or equal to 1500
// where interface.mtu < 1500 // Less than 1500
// where interface.mtu <= 1500 // Less than or equal to 1500
select {
deviceName: device.name,
interfaceName: interface.name,
intfMTU: interface.mtu
}
What have you used comparison operators for to extract new data from your network? Let us know and share your queries below