Add snmp_init_mib function to allow MIB tree to be reset using environment variables#21452
Draft
eskyuu wants to merge 2 commits intophp:masterfrom
Draft
Add snmp_init_mib function to allow MIB tree to be reset using environment variables#21452eskyuu wants to merge 2 commits intophp:masterfrom
eskyuu wants to merge 2 commits intophp:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have been trying to use the PHP SNMP extension in LibreNMS to replace calls to external snmp* programs. One issue I have come across is that there is no way to clear the MIB tree in the PHP SNMP extension. It becomes even worse with PHP-FPM where the MIB tree is persistent across different requests.
The above causes issues when a script wants to do multiple SNMP queries against incompatible MIBs because there is currently no way to clear the MIB tree and start again.
This PR add a new snmp_init_mib() function that frees up the existing MIB tree and then calls init_mib(), which will:
MIBDIRSenvironment variableMIBSenvironment variable (plus any IMPORTs)MIBFILESvariableI have chosen to only expose the one function above because the other functions like shutdown_mib(), init_mib_internals() netsnmp_read_module() require understanding how the net-snmp internals work to ensure everything is initialised properly. The proposed function can be used to clear the MIB tree back to the default state if the environment variables are not changed, or to reset to a known state if the environment variables are updated.
It's marked as draft until I have tested that it works.