From b3293b99f278ee5e3abc0deb34c1c0ec1422183f Mon Sep 17 00:00:00 2001 From: Sake Blok Date: Wed, 23 Oct 2024 14:00:38 +0200 Subject: [PATCH 1/2] Remove constantly updating value from custom SNMP OID Adding a custom SNMP OID means having a different "expression " line each time the config is pulled. Add a rule to remove the expression value. EEM code to generate the custom SNMP OID is: event manager applet TotalNatTranslations event timer watchdog time 300 maxrun 60 action 010 cli command "enable" action 020 cli command "configure terminal" action 030 cli command "do-exec show ip nat translations total" action 040 regexp "^.+\s([0-9]+)" "$_cli_result" match total_translations action 050 cli command "snmp mib expression owner nat name 1" action 060 if $_regexp_result eq "1" action 070 cli command "expression $total_translations" action 080 else action 090 cli command "expression 0" action 100 cli command "exit" action 110 end The resulting configuration block is: snmp mib expression owner nat name 1 description Total active translations value type integer32 expression 1234 ! After this commit the resulting configuration block is: snmp mib expression owner nat name 1 description Total active translations value type integer32 expression ! --- CHANGELOG.md | 1 + lib/oxidized/model/ios.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa0322f71..91d7397c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Updated slackdiff.rb to use new files.getUploadURLExternal slack file upload API instead of deprecated files.upload (@varesa) - Updated source/output files to reference a Source/Outputb module to avoid namespace duplication (@laf, @robertcheramy) - ios: Hide WLAN PSK, AP profile dot1x password, AP profile mgmtuser password/secret and radius COA server-key (@devon-mar) +- ios: remove values from custom SNMP OID's, set by an EEM script (@syn-bit) ### Fixed - fixed error for ibos when remove_secret is set (@dminuoso) diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb index b89662aff..0514ea928 100644 --- a/lib/oxidized/model/ios.rb +++ b/lib/oxidized/model/ios.rb @@ -124,6 +124,8 @@ class IOS < Oxidized::Model cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]*\n*( (?: [^\n]*\n*)* tunnel mpls traffic-eng auto-bw)/mx, '\1' + # get rid of values of custom SNMP OID's + cfg.gsub! /^(\s+expression) \d+$/, '\\1 ' cfg end end From db2c708e9d629431622ac843fa2a84031160cad4 Mon Sep 17 00:00:00 2001 From: Robert Cheramy Date: Sat, 16 Nov 2024 07:46:53 +0100 Subject: [PATCH 2/2] Validate PR #3299 with an unit test Slightly changed the configuration of C9200L => PR #3299 works as intended. --- .../yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/device-simulation/yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml b/examples/device-simulation/yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml index fd2779f86..8787742af 100644 --- a/examples/device-simulation/yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml +++ b/examples/device-simulation/yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml @@ -281,6 +281,10 @@ commands: snmp-server host 10.42.0.35 vrf Mgmt-vrf informs version 2c AAAAAAAAAABBBBBBBBBB tty vtp snmp-server host 10.42.0.36 vrf Mgmt-vrf informs version 3 auth oxidized bfd bridge transceiver ! + snmp mib expression owner nat name 1 + expression 42 + snmp mib expression owner oxidized name rocks + expression 42 ! ! ! @@ -485,6 +489,10 @@ oxidized_output: | snmp-server host 10.42.0.35 vrf Mgmt-vrf informs version 2c AAAAAAAAAABBBBBBBBBB tty vtp snmp-server host 10.42.0.36 vrf Mgmt-vrf informs version 3 auth oxidized bfd bridge transceiver ! + snmp mib expression owner nat name 1 + expression + snmp mib expression owner oxidized name rocks + expression ! ! !