Skip to main content

Hi Team,

I want to add only admin status up interfaces condition, CDP LLDP neighbor info in below query, please help me on this.

Extra question- 1. any method to shirk the results to only getting WAN interfaces any idea on this.
2. want to add one more column to fetch circuit id details from Interface or Interface description.

NQE Query-
 

pattern_interfaces = "*WAN *"];

testPatterns(s, p) = 
max (foreach pattern in p
select matches(toLowerCase(s), toLowerCase(pattern)));

foreach device in network.devices
foreach interface in device.interfaces
let platform = device.platform
let ethernet = interface.ethernet
where isPresent(interface.description)
where testPatterns(interface.description, pattern_interfaces)
select {
  test: testPatterns(interface.description, pattern_interfaces),
  deviceName: device.name,
  Location: device.locationName,
  Tags: device.tagNames,
  Vendor: platform.vendor,
  Model: platform.model,
  interfaceName: interface.name,
  negotiatedSpeed: ethernet.negotiatedPortSpeed,
  negotiatedMode: ethernet.negotiatedDuplexMode,
  description: interface.description,
  operStatus: interface.operStatus,
  adminStatus: interface.adminStatus
}

 

Hello @Nand 


When you want to filter on something you use the `where` clause with a boolean outcome e.g. True False. 

Below we evaluate interface.adminStatus == AdminStatus.UP which is an enumeration of interface status.

You can lookup CDP in the data model, you can get an example query to help you see how to retrieve data and add it to the select statement.

 

pattern_interfaces = s"*WAN *"];

testPatterns(s, p) =
max (foreach pattern in p
select matches(toLowerCase(s), toLowerCase(pattern)));

foreach device in network.devices
foreach interface in device.interfaces
let platform = device.platform
let ethernet = interface.ethernet
let cdp = interface.cdp
where interface.adminStatus == AdminStatus.UP
where isPresent(interface.description)
where testPatterns(interface.description, pattern_interfaces)
select {
deviceName: device.name,
Location: device.locationName,
Tags: device.tagNames,
Vendor: platform.vendor,
Model: platform.model,
Neighbors: cdp.neighbors,
interfaceName: interface.name,
negotiatedSpeed: ethernet.negotiatedPortSpeed,
negotiatedMode: ethernet.negotiatedDuplexMode,
description: interface.description,
operStatus: interface.operStatus,
adminStatus: interface.adminStatus
}


Hope that helps.​​​​​​

-g


Thanks @GaryB ,

Any documentation or video link or any course suggest to know more about NQE Query.


Can you also help me out for this-

want to add one more column to fetch circuit id details from Interface or Interface description.

Example- like this.

                       Interface Description                                         Circuit id

WAN - Verizon MPLS VPN:Graw; Site-Circuit: E3003336 | E3003336


@Nand and Inside Forward Enterprised there is an NQE Tutorial.  It is directly under the NQE Library down the left hand menu.  That is a self paced course.  Also at the top of the NQE community page are some “pinned” comments.  There is a set of videos by Mike Lossman that are vey handy.


@Nand and Inside Forward Enterprised there is an NQE Tutorial.  It is directly under the NQE Library down the left hand menu.  That is a self paced course.  Also at the top of the NQE community page are some “pinned” comments.  There is a set of videos by Mike Lossman that are vey handy.

Thanks Henrie


Hi @Nand - 

Here are links to the community resources @Tyson Henrie recommended for learning NQE . You can always find them at the top of the NQE space.

 

@Mike ‘s NQE tutorials that cover the fundamentals:

 

And @devecis and @Andreas’s video on writing better queries is a great watch to learn how our NQE experts write queries that are easy to maintain, scale, and troubleshoot. 

 

Dave


@Nand 

 

Here is how you can parse the CircuitID from interface.description

 

interface_description =
"WAN - Verizon MPLS VPN:Graw; Site-Circuit: E3003336 | E3003336";

getCircuitId(intDescr) =
max(foreach x in i0]
let fix = replace(replace(intDescr, " ", "_"), "_|_", " ")
let match = patternMatch(fix, `{descr:string} {circuitId:string}`)
select {
intfDescr: replace(match.descr, "_", " "), circuitId: match.circuitId
});

foreach x in i0]
let match = getCircuitId(interface_description)
select { intfDesc: match.intfDescr, circuitId: match.circuitId }

 


Thank you so much @GaryB  for the resolution. I have upcoming concern related to this data. I have raised another question for this.


Reply