Skip to content

Commit

Permalink
Fix inputs.snmp init when no mibs installed (influxdata#9050)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hipska authored Mar 30, 2021
1 parent 9c54c8e commit 66c6396
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions plugins/inputs/snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,22 @@ func (f *Field) init() error {
return nil
}

_, 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
// 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
}

//TODO use textual convention conversion from the MIB

f.initialized = true
return nil
}
Expand Down

0 comments on commit 66c6396

Please sign in to comment.