Skip to main content
Solved

WAN Interfaces Inventory from NQE query


Forum|alt.badge.img
  • Spotter
  • 9 replies

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
}

Best answer by GaryB

@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 [0]
      let fix = replace(replace(intDescr, " ", "_"), "_|_", " ")
      let match = patternMatch(fix, `{descr:string} {circuitId:string}`)
      select {
        intfDescr: replace(match.descr, "_", " "), circuitId: match.circuitId
      });

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

 

View original
Did this topic help you find an answer to your question?

7 replies

Forum|alt.badge.img+1
  • Employee
  • 55 replies
  • June 25, 2024

 

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 = ["*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


Forum|alt.badge.img
  • Author
  • Spotter
  • 9 replies
  • June 25, 2024

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


Tyson Henrie
Employee
Forum|alt.badge.img+1

@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.


Forum|alt.badge.img
  • Author
  • Spotter
  • 9 replies
  • June 25, 2024
Tyson Henrie wrote:

@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


davetee
Community Manager
  • Community Manager
  • 25 replies
  • June 25, 2024

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


Forum|alt.badge.img+1
  • Employee
  • 55 replies
  • Answer
  • June 25, 2024

@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 [0]
      let fix = replace(replace(intDescr, " ", "_"), "_|_", " ")
      let match = patternMatch(fix, `{descr:string} {circuitId:string}`)
      select {
        intfDescr: replace(match.descr, "_", " "), circuitId: match.circuitId
      });

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

 


Forum|alt.badge.img
  • Author
  • Spotter
  • 9 replies
  • June 26, 2024

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings