Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove constantly updating value from custom SNMP OID #3299

Merged
merged 2 commits into from
Nov 16, 2024

Conversation

syn-bit
Copy link
Contributor

@syn-bit syn-bit commented Oct 23, 2024

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

  • Passes rubocop code analysis (try rubocop --auto-correct)
  • Tests added or adapted (try rake test)
  • Changes are reflected in the documentation
  • User-visible changes appended to CHANGELOG.md

Description

@robertcheramy robertcheramy self-assigned this Nov 8, 2024
@robertcheramy robertcheramy added this to the 0.31 milestone Nov 8, 2024
syn-bit and others added 2 commits November 16, 2024 07:42
Adding a custom SNMP OID means having a different "expression <value>"
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 <value removed>
!
Slightly changed the configuration of C9200L => PR ytti#3299 works as
intended.
@robertcheramy robertcheramy force-pushed the ios-remove-expression-values branch from 1356be2 to db2c708 Compare November 16, 2024 06:47
@robertcheramy
Copy link
Collaborator

Rebased on ytti/master and modified an unit test to test the change.

@robertcheramy robertcheramy merged commit 41ad7c1 into ytti:master Nov 16, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants