ytti / oxidized

Oxidized is a network device configuration backup tool. It's a RANCID replacement!
Apache License 2.0
2.82k stars 929 forks source link

Remove constantly updating value from custom SNMP OID #3281

Closed syn-bit closed 1 month ago

syn-bit commented 1 month ago

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 !

Pre-Request Checklist

Description

robertcheramy commented 1 month ago

This is an uncommon use case for me, but if you made the effort of submitting a PR, it is worth integrating it into oxidized. Thanks for your PR!

The gsub should be placed within the show running-config command (not cmd :all), before returning the resulting cfg: https://github.com/ytti/oxidized/blob/3ec983b4607ffb14c02a82b27a339aaf620f4f8c/lib/oxidized/model/ios.rb#L121

Also please document your Change in CHANGELOG.md

syn-bit commented 1 month ago

Hi Robert,

Thanks for reviewing my commit and setting me onto the straight path ;-) A new PR had been submitted and I hope it is now OK. I just discovered oxidized and had to make this change to prevent a new config every time the config is checked.

Thanks for maintaining oxidized!

Cheers Met vriendelijke groet,

Sake Blok Relational therapist for computer systems

SYN-bit Deep Traffic Analysis http://www.SYN-bit.nl

On 9 Oct 2024, at 18:15, Robert Chéramy @.***> wrote:

This is an uncommon use case for me, but if you made the effort of submitting a PR, it is worth integrating it into oxidized. Thanks for your PR!

The gsub should be placed within the show running-config command (not cmd :all), before returning the resulting cfg: https://github.com/ytti/oxidized/blob/3ec983b4607ffb14c02a82b27a339aaf620f4f8c/lib/oxidized/model/ios.rb#L121

Also please document your Change in CHANGELOG.md

— Reply to this email directly, view it on GitHub https://github.com/ytti/oxidized/pull/3281#issuecomment-2402758627, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJWYCNREXS5DVGXB3QDKSLZ2VJCXAVCNFSM6AAAAABPUKBPZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBSG42TQNRSG4. You are receiving this because you authored the thread.