Skip to content
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

SNMP Plugin - Telegraf crash when mib file is missing #16153

Closed
PFraire opened this issue Nov 6, 2024 · 5 comments · Fixed by #16155
Closed

SNMP Plugin - Telegraf crash when mib file is missing #16153

PFraire opened this issue Nov 6, 2024 · 5 comments · Fixed by #16155
Labels
bug unexpected problem or unintended behavior

Comments

@PFraire
Copy link

PFraire commented Nov 6, 2024

Relevant telegraf.conf

[agent]
  snmp_translator = "gosmi"

[[inputs.snmp]]
  agents = ["udp://xxx.xxx.xxx.xxx:161"]

  timeout = "15s"
  version = 2
  community = "CCCCCCCCCCC"
  retries = 10
  max_repetitions = 10
  #interval = "5m"
  interval = "24h"
  unconnected_udp_socket = true
  agent_host_tag = "source"
  tagexclude = ["host"]

  [[inputs.snmp.field]]
    # "An administratively-assigned name for this managed\n node. By convention, this is the node\'s fully-qualified\n domain name. If the name is unknown, the value is\n the zero-length string."
    oid = ".1.3.6.1.2.1.1.5.0"
    name = "SNMPv2-MIB::sysName"
    is_tag = true

  [[inputs.snmp.table]]
    # "hwIFExtIndex is the unique identifier of the table. It is written when the table is created and cannot be modified later.\n The table describes the extended attributes of an interface, such as the Layer 2/Layer 3 identifier and frame type of the interface."
    #oid = ".1.3.6.1.4.1.2011.5.25.41.1.1.1"
    name = "HUAWEI-IF-EXT-MIB::hwIFExtTable"
    inherit_tags = ["SNMPv2-MIB::sysName"]
    index_as_tag = true


  [[inputs.snmp.table.field]]
    # "This object indicates the interface index."
    oid = ".1.3.6.1.4.1.2011.5.25.41.1.1.1.1.1"
    name = "HUAWEI-IF-EXT-MIB::hwIFExtIndex"

  [[inputs.snmp.table.field]]
    # "This object indicates the Layer 2/Layer 3 switching flag of an interface.\n According to the switching command, note the following:\n When Layer2(1) is 1, the interface switches from Layer 3 mode to Layer 2 mode. When Layer3(2) is 2, the interface switches from Layer 2 mode to Layer 3 mode."
    oid = ".1.3.6.1.4.1.2011.5.25.41.1.1.1.1.2"
    name = "HUAWEI-IF-EXT-MIB::hwIFExtLayer"
    conversion = "enum(1)"

  [[inputs.snmp.table.field]]
    # "This object indicates the type of frames that a VLAN virtual interface receives. \n Frame formats include ethernetII(1), ethernetII(2), ethernet8022(3), and ethernet8023. \n The value for the ethernetII(1) format is 1. Currently, only ethernetII(1) is supported."
    oid = ".1.3.6.1.4.1.2011.5.25.41.1.1.1.1.3"
    name = "HUAWEI-IF-EXT-MIB::hwIFExtFrameType"
    conversion = "enum(1)"

  [[inputs.snmp.table.field]]
    # "This object indicates the interval for collecting traffic statistics for an interface. The value ranges from 0 to 600, in seconds. The default value is 300."
    oid = ".1.3.6.1.4.1.2011.5.25.41.1.1.1.1.4"
    name = "HUAWEI-IF-EXT-MIB::hwIFExtFlowStatInterval"

Logs from Telegraf

There is no relevant log

System info

Telegraf version: 1.32.0 OS: SUSE

Docker

No response

Steps to reproduce

When running telegraf with snmp pluging, if a needed mib file is missing following error occurs.
The solution is simple, putting the missing mib file into /usr/share/snmp/mibs directory or the configured one.

Expected behavior

Trap this error and log the mib file that is missing in order to make easy to locate the problem.

Actual behavior

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

Additional info

No response

@PFraire PFraire added the bug unexpected problem or unintended behavior label Nov 6, 2024
@Hipska
Copy link
Contributor

Hipska commented Nov 6, 2024

Could you please add relevant config? The snmp plugin seems to run a Gather cycle and is trying to convert/format an snmp enum, as far as I can see, it doesn't do that by default/automatically. So please add at least your config for that specific inputs.snmp.table.field item..

The relevant log is the panic and stack trace..

@PFraire
Copy link
Author

PFraire commented Nov 6, 2024

Hi!
My telegraf configuration has 796 snmp plugins.

2024-11-06T13:08:44Z I! Starting Telegraf 1.32.0 brought to you by InfluxData the makers of InfluxDB
2024-11-06T13:08:44Z I! Available plugins: 235 inputs, 9 aggregators, 32 processors, 26 parsers, 62 outputs, 6 secret-stores
2024-11-06T13:08:44Z I! Loaded inputs: ping (6x) snmp (796x)
2024-11-06T13:08:44Z I! Loaded aggregators: derivative
2024-11-06T13:08:44Z I! Loaded processors: converter strings

And my snmp directory has 360 files.

I was not able to isolate witch file was the missing one that generates the error.

I posted an example one.
As you mention enum, includes enum lines.

Regards

@Hipska
Copy link
Contributor

Hipska commented Nov 6, 2024

Hi @PFraire, could you check if telegraf is not crashing anymore with the artefacts from #16155?

The logs should now inform that telegraf was unable to format the value.

@PFraire
Copy link
Author

PFraire commented Nov 6, 2024

Hi!
I removed the mib file associated to this example and was able to reproduce the error.
Now I'll try the new version, an let you know.

@PFraire
Copy link
Author

PFraire commented Nov 6, 2024

This is telegraf log with the new version, I don't see the messages you refer, but telegraf did not crashed.
Looks like 1.33 version has already addressed this issue.

2024-11-06T17:39:55Z I! Starting Telegraf 1.33.0-2f7f2e7e brought to you by InfluxData the makers of InfluxDB
2024-11-06T17:39:55Z I! Available plugins: 236 inputs, 9 aggregators, 33 processors, 26 parsers, 62 outputs, 6 secret-stores
2024-11-06T17:39:55Z I! Loaded inputs: ping (6x) snmp (135x)
2024-11-06T17:39:55Z I! Loaded aggregators: derivative
2024-11-06T17:39:55Z I! Loaded processors: converter strings
2024-11-06T17:39:55Z I! Loaded secretstores:
2024-11-06T17:39:55Z W! Outputs are not used in testing mode!
2024-11-06T17:39:55Z I! Tags enabled: host=arcchor_gde_psp_ma01
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "hwaddr" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead
2024-11-06T17:41:33Z W! DeprecationWarning: Value "enum(1)" for option "field.conversion" of plugin "inputs.snmp" deprecated since version 1.33.0 and will be removed in 2.0.0: Use 'displayhint' instead

Regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants