Fix inputs.snmp init when no mibs installed (#9050)

This commit is contained in:
Thomas Casteleyn 2021-03-30 21:08:14 +02:00 committed by GitHub
parent 9c54c8e233
commit 66c639668c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 12 deletions

View File

@ -255,6 +255,8 @@ func (f *Field) init() error {
return nil return nil
} }
// check if oid needs translation or name is not set
if strings.ContainsAny(f.Oid, ":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") || f.Name == "" {
_, oidNum, oidText, conversion, err := SnmpTranslate(f.Oid) _, oidNum, oidText, conversion, err := SnmpTranslate(f.Oid)
if err != nil { if err != nil {
return fmt.Errorf("translating: %w", err) return fmt.Errorf("translating: %w", err)
@ -266,8 +268,8 @@ func (f *Field) init() error {
if f.Conversion == "" { if f.Conversion == "" {
f.Conversion = conversion f.Conversion = conversion
} }
//TODO use textual convention conversion from the MIB //TODO use textual convention conversion from the MIB
}
f.initialized = true f.initialized = true
return nil return nil