Hi!
When running telegraf with snmp pluging, if a needed mib file is missing the following error occurs:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xcc39ed]
goroutine 1040 [running]:
github.com/sleepinggenius2/gosmi/models.Node.FormatValue(...)
/go/pkg/mod/github.com/sleepinggenius2/gosmi@v0.4.4/models/format.go:127
github.com/influxdata/telegraf/internal/snmp.(*gosmiTranslator).SnmpFormatEnum(0xc002011ac1?, {0xc00406bbc0?, 0x9f7c5c8?}, {0x7be8e00, 0xf9726a8}, 0x1)
/go/src/github.com/influxdata/telegraf/internal/snmp/translator_gosmi.go:69 +0x18d
github.com/influxdata/telegraf/internal/snmp.(*Field).Convert(0xc0062f77a0, {{0x7be8e00, 0xf9726a8}, {0xc00406bbc0, 0x28}, 0x2})
/go/src/github.com/influxdata/telegraf/internal/snmp/field.go:302 +0xf47
github.com/influxdata/telegraf/internal/snmp.Table.Build.func1({{0x7be8e00, 0xf9726a8}, {0xc00406bbc0, 0x28}, 0x2})
/go/src/github.com/influxdata/telegraf/internal/snmp/table.go:208 +0x268
github.com/gosnmp/gosnmp.(*GoSNMP).walk(0xc005f9cb00, 0xa5, {0xc002014451?, 0xc0066ecd50?}, 0xc0066ecd50)
/go/pkg/mod/github.com/gosnmp/gosnmp@v1.37.0/walk.go:152 +0xcda
github.com/gosnmp/gosnmp.(*GoSNMP).BulkWalk(...)
/go/pkg/mod/github.com/gosnmp/gosnmp@v1.37.0/gosnmp.go:590
github.com/influxdata/telegraf/internal/snmp.GosnmpWrapper.Walk({0xc00649f980?}, {0xc002014451?, 0xc00649f980?}, 0x13?)
/go/src/github.com/influxdata/telegraf/internal/snmp/wrapper.go:40 +0x45
github.com/influxdata/telegraf/internal/snmp.Table.Build({{0xc0020143c1, 0x22}, {0xc002f42e50, 0x1, 0x1}, 0x1, {0xc0001ae008, 0xc, 0xc}, {0x0, ...}, ...}, ...)
/go/src/github.com/influxdata/telegraf/internal/snmp/table.go:182 +0x4b1
github.com/influxdata/telegraf/plugins/inputs/snmp.(*Snmp).gatherTable(0xc001fb2780, {0xa07b000, 0xc006743300}, {0xa0371c0, 0xc005f9cb00}, {{0xc0020143c1, 0x22}, {0xc002f42e50, 0x1, 0x1}, ...}, ...)
/go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:134 +0x87
github.com/influxdata/telegraf/plugins/inputs/snmp.(*Snmp).Gather.func1(0x0?, {0xc0027a6701, 0x16})
/go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:122 +0x448
created by github.com/influxdata/telegraf/plugins/inputs/snmp.(*Snmp).Gather in goroutine 136
/go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:102 +0x66
The solution is simple, putting the missing mib file into /usr/share/snmp/mibs directory or the configured one.
This is just a report only to, if possible, ask to trap this error and log the mib file that is missing in order to make easy to locate the problem.
Telegraf version: 1.32.0
OS: SUSE
I am not quite sure if this is the correct place to put this report, if not please redirect me.
Regards;
Pablo