Fix inputs.snmp init when no mibs installed (#9050)
This commit is contained in:
parent
9c54c8e233
commit
66c639668c
|
|
@ -255,19 +255,21 @@ func (f *Field) init() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
_, oidNum, oidText, conversion, err := SnmpTranslate(f.Oid)
|
||||
if err != nil {
|
||||
return fmt.Errorf("translating: %w", err)
|
||||
// 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)
|
||||
if err != nil {
|
||||
return fmt.Errorf("translating: %w", err)
|
||||
}
|
||||
f.Oid = oidNum
|
||||
if f.Name == "" {
|
||||
f.Name = oidText
|
||||
}
|
||||
if f.Conversion == "" {
|
||||
f.Conversion = conversion
|
||||
}
|
||||
//TODO use textual convention conversion from the MIB
|
||||
}
|
||||
f.Oid = oidNum
|
||||
if f.Name == "" {
|
||||
f.Name = oidText
|
||||
}
|
||||
if f.Conversion == "" {
|
||||
f.Conversion = conversion
|
||||
}
|
||||
|
||||
//TODO use textual convention conversion from the MIB
|
||||
|
||||
f.initialized = true
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue