-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
MIB files named differently to the module identity are not discovered #10446
Comments
Something else I have remembered - it is valid for multiple modules to be included in a single MIB file, so gosmi/telegraf will need to be fixed to allow this in order to retain compatibility with snmptranslate. |
FWIW telegraf does load all files in the MIB paths. The only problem is indeed when a MIB imports another one that not yet has been loaded and that one has a different naming. This is something that should be handled by telegraf: keep track if a MIB needs another one, and try to load it again when it finds that other one. Figured this out also when debugging a strange thing: sleepinggenius2/gosmi#34 |
#10802 switches back to using netsnmp/snmptranslate by default. netsnmp doesn't require files to match the module name, so it should fix this issue for most users. We should keep this issue open because users who configure telegraf to use gosmi will still hit this issue. We still need to either make changes to telegraf and/or gosmi upstream if we want it to work with the same file naming that netsnmp allows. We should also document the file naming requirements of telegraf's gosmi translator so people know that it's different than netsnmp. |
The file naming doesn't need to be correct when Telegraf would implement a better/smarter loading order. This is also what the maintainer of GoSMI explains. |
LoadMibsFromPath
assumes that MIB files are all named exactly as the module name, and asks gosmi to load these modules. gosmi then attempts to load files named exactly as the module name.This is a common way MIB files are named - however - this is not required by other SNMP software, and many vendors ship MIB files in different naming formats, for example:
MODULENAME.txt
MODULENAME.mib
mib-foo-bar.txt
mib-foo
etc.
In the above cases, telegraf asks gosmi to load modules named the same as the filename - i.e.
MODULENAME.txt
etc. - which is obviously not correct asMODULENAME.txt
is not the module name -MODULENAME
is. Extensions cannot be stripped to determine module names (this would not solve examples 3 and 4 above).Adding the requirement for MIB files to be named as the module name is not compatible with
snmptranslate
.There are 2 sub-problems to solve here:
LoadModule
also expects to find a file named exactly as the module name or with what it thinks are good common extensions (i.e. .txt, .mib, etc.) which solves examples 1 and 2 above, but not 3 and 4.gosmi has a
parser.Parse
function which takes a filename, rather than an SNMP module - and is what gosmi uses internally when it has discovered the filename (see https://github.com/sleepinggenius2/gosmi/blob/d38face97ec784bf7044de0638c431e5fd6dd8b2/smi/internal/module.go#L326). This (and callingBuildModule
) may be a valid alternative to callingLoadModule
- but I am not certain what will happen if a file needs another parent module which has not yet been loaded - i.e. gosmi may need the filenames to still match (I have not yet read all the code).The text was updated successfully, but these errors were encountered: