Skip to content

Add Cisco Err-Disable interface event trap handler#13855

Merged
laf merged 18 commits intolibrenms:masterfrom
bonzo81:CiscoErrDisableInterfaceEvent
Apr 1, 2022
Merged

Add Cisco Err-Disable interface event trap handler#13855
laf merged 18 commits intolibrenms:masterfrom
bonzo81:CiscoErrDisableInterfaceEvent

Conversation

@bonzo81
Copy link
Copy Markdown
Contributor

@bonzo81 bonzo81 commented Mar 16, 2022

Please give a short description what your pull request is for

SNMP Trap hander and test for Cisco Err-Disable Interface Event (Rev1) trap. Requires CISCO-ERR-DISABLE-MIB.

thanks to @Jellyfrog for help with test

DO NOT DELETE THE UNDERLYING TEXT

Please note

Please read this information carefully. You can run ./lnms dev:check to check your code before submitting.

  • Have you followed our code guidelines?
  • If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.
  • If my Pull Request makes discovery/polling/yaml changes, I have added/updated test data.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@bonzo81
Copy link
Copy Markdown
Contributor Author

bonzo81 commented Mar 17, 2022

Although the handler and test work, I wasn't sure if my method to extract the ifIndex from the trap using toString then preg_match was the best way to do that. I looked at using substr but couldn't see how to use that when the required string could be single or multiple characters. A review of that would be appreciated.

Comment on lines +45 to +47
$oidText = $trap->toString(true);

preg_match('/.cErrDisableIfStatusCause\.(.*?)\./', $oidText, $ifIndex);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should replace toString() with $trap->findOid('CISCO-ERR-DISABLE-MIB::cErrDisableIfStatusCause')

How you want to get the ifIndex is up to you, one way would be;

>>> explode(".", $trap->findOid('CISCO-ERR-DISABLE-MIB::cErrDisableIfStatusCause'))
=> [
     "CISCO-ERR-DISABLE-MIB::cErrDisableIfStatusCause",
     "858734311",
     "0",
   ]

Comment on lines +45 to +47
$oidText = $trap->toString(true);

preg_match('/.cErrDisableIfStatusCause\.(.*?)\./', $oidText, $ifIndex);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should replace toString() with $trap->findOid('CISCO-ERR-DISABLE-MIB::cErrDisableIfStatusCause')

How you want to get the ifIndex is up to you, one way would be;

>>> explode(".", $trap->findOid('CISCO-ERR-DISABLE-MIB::cErrDisableIfStatusCause'))
=> [
     "CISCO-ERR-DISABLE-MIB::cErrDisableIfStatusCause",
     "858734311",
     "0",
   ]

Copy link
Copy Markdown
Member

@laf laf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@laf laf merged commit 5c53f29 into librenms:master Apr 1, 2022
@laf
Copy link
Copy Markdown
Member

laf commented Apr 1, 2022

Great work @bonzo81 👍

@librenms-bot
Copy link
Copy Markdown

This pull request has been mentioned on LibreNMS Community. There might be relevant details there:

https://community.librenms.org/t/22-4-0-changelog/18610/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants