Skip to content

Use gosmi for SNMP traps#9307

Closed
loganmc10 wants to merge 1 commit intoinfluxdata:masterfrom
loganmc10:gosmi
Closed

Use gosmi for SNMP traps#9307
loganmc10 wants to merge 1 commit intoinfluxdata:masterfrom
loganmc10:gosmi

Conversation

@loganmc10
Copy link
Copy Markdown
Contributor

@loganmc10 loganmc10 commented May 26, 2021

As requested in: #5720 (comment)

I'm submitting a very early implementation of using gosmi to translate SNMP OIDs for the snmp_trap plugin.

Using snmptranslate does not work well. It's slow to call it, and it requires a mutex lock to deal with the cache, which pretty much destroys any parallelism.

We ingest about 30 traps per second. Because of the varying OID index values coming in, the snmptranslate cache didn't really work as expected for us. Telegraf was pinned at 100% CPU usage.

I'm not a professional Go programmer and I'm not so great at unit tests. I'm hoping someone can take it from here and finish it off. We're using this implementation daily and it appears to work well for us. (less than 1% CPU usage from Telegraf to process those 30 traps/second).

The biggest shortfall of what I've upload here is that it uses a hardcoded path of /usr/share/snmp/mibs for the MIBs, it should probably be something that is configured as a plugin option. Also, the folder recursion is not very good, it doesn't go multiple levels into the folder structure.

There is also a gosmi.Exit() function that should be called to clean things up that I never implemented here.

@Hipska Hipska added area/snmp feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels May 26, 2021
@reimda
Copy link
Copy Markdown
Contributor

reimda commented May 28, 2021

Thanks @loganmc10 for the PR. This is a good start

To address the hardcoded path, on platforms that use net-snmp maybe we should use net-snmp's mib paths? We could have telegraf query net-snmp on startup with net-snmp-config --default-mibdirs or snmptranslate -Dinit_mib .1.3 2>&1 |grep MIBDIR (see https://net-snmp.sourceforge.io/wiki/index.php/TUT:Using_and_loading_MIBS)

@loganmc10
Copy link
Copy Markdown
Contributor Author

One of the benefits of this change would be to remove the dependency on net-snmp, so it would probably be better to either read the env variable MIBDIRS (which is what net-snmp uses), or add an option to the plugin that defaults to /usr/share/snmp/mibs

@MyaLongmire MyaLongmire self-assigned this Jun 1, 2021
@MyaLongmire MyaLongmire mentioned this pull request Jun 8, 2021
2 tasks
@loganmc10
Copy link
Copy Markdown
Contributor Author

Closing in favour of #9343

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

Labels

area/snmp feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants