Skip to main content

I want to create a custom interface description nqe query in Forward Networks.

Requirement is to getting only WAN, INT interfaces information through the query. I have used below logic through it i am not getting the results. Please help me out.

 

foreach device in network.devices
foreach interface in device.interfaces
let platform = device.platform
where interface.description=="WAN"
select {
  deviceName: device.name,
  Location: device.locationName,
   Tags: device.tagNames,
  Vendor: platform.vendor,
  Model: platform.model,
  interfaceName: interface.name,
  description: interface.description,
operStatus: interface.operStatus,
adminStatus: interface.adminStatus,
cdpNeighborsCount: length(interface.cdp.neighbors),
  lldpNeighborsCount: length(interface.lldp.neighbors) 
}
 

@Nand 

Hello great question. The evaluation you are looking for requires a “glob” match since the string “WAN” can be anywhere in the interface description.

Try using the builtin function “matches” https://fwd.app/docs/nqe/std-lib/matches/

Because interface.description maybe “null” we have to check that a description exists with the isPresent function  https://fwd.app/docs/nqe/std-lib/isPresent/

 

foreach device in network.devices
foreach interface in device.interfaces
let platform = device.platform
where isPresent(interface.description)
where matches(interface.description, "*WAN*")
select {
deviceName: device.name,
Location: device.locationName,
Tags: device.tagNames,
Vendor: platform.vendor,
Model: platform.model,
interfaceName: interface.name,
description: interface.description,
operStatus: interface.operStatus,
adminStatus: interface.adminStatus,
cdpNeighborsCount: length(interface.cdp.neighbors),
lldpNeighborsCount: length(interface.lldp.neighbors)
}

 


Thank you so much 

@GaryB 

 

One last query can you please also help me for getting L2 and L3 interface column in existing query.


Hello @Nand , Our interface model is very extensive, Can you be more specific of the information you are looking for ?


@GaryB ,

 

want to add more in this existing query-
       1. Interface Layer (L2 or L3)

  1. double logic for description like “WAN” and “INT” or “INT’ and “int” at the same time.
  2. Port speed of Interface

Hello @Nand 

You might consider this logic. Depending on how your descriptions are configured you might need to be more specific with your patterns.


See other ethernet details: https://fwd.app/docs/nqe/data-model/type_ethernet/​​​​​​

 

pattern_interfaces = _"*WAN*", "*INT*", "*otherstuff*"];

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,
cdpNeighborsCount: length(interface.cdp.neighbors),
lldpNeighborsCount: length(interface.lldp.neighbors)
}

 


Reply