Question

NQE for confirming configuration within Cisco switch interfaces

  • 29 November 2023
  • 4 replies
  • 121 views

Badge

Hi!  Looking for help with an NQE to scan/identify configuration for all Cisco switches within a workspace that contain one of two QOS policy maps within at least one of the device interfaces.

 

For example 

interface gigabitethernet1/1

 service-policy output 1P7Q3T 

or

service-policy output 1P7Q1T

 

Thanks        


4 replies

Userlevel 3
Badge

@rrogers33 You can leverage blockMatches Try the following test.

test =

"""
interface TenGigabitEthernet1/0/2
description foo
switchport access vlan 17
switchport mode access
no logging event link-status
no cdp enable
udld port disable
no snmp trap link-status
storm-control broadcast level bps 50m
storm-control multicast level bps 50m
spanning-tree bpduguard enable
service-policy output 1P7Q3T


interface TenGigabitEthernet1/0/3
description foo
switchport access vlan 17
switchport mode access
no logging event link-status
no cdp enable
udld port disable
no snmp trap link-status
storm-control broadcast level bps 50m
storm-control multicast level bps 50m
spanning-tree bpduguard enable
service-policy output 1P7Q1T
""";


pattern = ```
interface {intf: string}
service-policy output {policy: string}
```;


foreach x in [0]
let config = parseConfigBlocks(OS.UNKNOWN, test)
let matches = blockMatches(config, pattern)
foreach match in matches
let violation = match.data.policy not in ["1P7Q3T", "1P7Q1T"]
select {violation, intf: match.data.intf, policy: match.data.policy}

 

Userlevel 2

Another option (available since 23.11), in case you are looking to run some ad-hoc searches (as opposed to having a saved query that you can use as a Verification or in Inventory+), is to use our “Config Search” parameterized query in the Forward Library. You can just open this query, set the config pattern you are looking for, and then run the query.  

The query is “Forward Library/Devices/Config Search” (you can also search for it). Open the query, click the “Parameters” button, and then enter the config pattern you like. You can also specify OSes and device name globs in case you want to narrow down the search. See the screenshot below for the example with a pattern that is close to what you are looking for:

 

 

Badge

Thank you very much for the responses.  @GaryB, I will play around with that query.  @Andreas Unfortunately for the “Config Search” I am not finding that as an option in our NQE Library.  Perhaps we are at an older code.

Userlevel 3
Badge

@rrogers33 Yes you will need 23.11 for the new “Edit Parameterized Query” feature in NQE

Reply