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: with no mibs installed, snmp panics #10300

Closed
powersj opened this issue Dec 17, 2021 · 0 comments · Fixed by #10301
Closed

snmp: with no mibs installed, snmp panics #10300

powersj opened this issue Dec 17, 2021 · 0 comments · Fixed by #10301
Labels
area/snmp bug unexpected problem or unintended behavior

Comments

@powersj
Copy link
Contributor

powersj commented Dec 17, 2021

Relevent telegraf.conf

[[inputs.snmp]]
  agents = [ "synology.local:161" ]
  version = 2
  timeout = "5s"
  retries = 3
  community = "public"
  name = "system"

  [[inputs.snmp.field]]
      name = "hostname"
      oid = "SNMPv2-MIB::sysName.0"
      is_tag = true

  [[inputs.snmp.table]]
    name = "synotable"
    oid = "SYNOLOGY-DISK-MIB::diskTable"
    inherit_tags = [ "hostname" ]

  [[inputs.snmp.table.field]]
    name = "diskID"
    oid = "SYNOLOGY-DISK-MIB::diskID"
    is_tag = true

[[outputs.file]]

System info

master

Docker

No response

Steps to reproduce

On a system with no snmp installed, telegraf panics when trying to use an snmp plugin.

Expected behavior

Error message about no mibs found, no panic

Actual behavior

2021-12-17T20:23:41Z I! Starting Telegraf 1.22.0-94cf4952
2021-12-17T20:23:41Z I! Loaded inputs: snmp
2021-12-17T20:23:41Z I! Loaded aggregators: 
2021-12-17T20:23:41Z I! Loaded processors: 
2021-12-17T20:23:41Z I! Loaded outputs: file
2021-12-17T20:23:41Z I! Tags enabled: host=ryzen
2021-12-17T20:23:41Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"ryzen", Flush Interval:10s
2021-12-17T20:23:41Z D! [agent] Initializing plugins
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x2c1a2b3]

goroutine 1 [running]:
github.com/influxdata/telegraf/internal/snmp.LoadMibsFromPath.func1({0x4e080ff, 0x14}, {0x0, 0x0}, {0x0, 0x2c19ac0})
	/home/powersj/telegraf/internal/snmp/translate.go:60 +0x53
path/filepath.Walk({0x4e080ff, 0x14}, 0xc00161f640)
	/usr/lib/go/src/path/filepath/path.go:503 +0x50
github.com/influxdata/telegraf/internal/snmp.LoadMibsFromPath({0xc00040e960, 0x1, 0xc00161f6c8}, {0x586ae70, 0xc000a53d40})
	/home/powersj/telegraf/internal/snmp/translate.go:57 +0x29a
github.com/influxdata/telegraf/plugins/inputs/snmp.(*Snmp).Init(0xc00061bce0)
	/home/powersj/telegraf/plugins/inputs/snmp/snmp.go:102 +0x50
github.com/influxdata/telegraf/models.(*RunningInput).Init(0xc00161f758)
	/home/powersj/telegraf/models/running_input.go:82 +0x35
github.com/influxdata/telegraf/agent.(*Agent).initPlugins(0xc0007280c8)
	/home/powersj/telegraf/agent/agent.go:189 +0x96
github.com/influxdata/telegraf/agent.(*Agent).Run(0xc0007280c8, {0x5802308, 0xc000d616c0})
	/home/powersj/telegraf/agent/agent.go:105 +0x185
main.runAgent({0x5802308, 0xc000d616c0}, {0x83ae658, 0x0, 0x0}, {0x83ae658, 0x0, 0x0})
	/home/powersj/telegraf/cmd/telegraf/telegraf.go:312 +0xc57
main.reloadLoop({0x83ae658, 0x0, 0x0}, {0x83ae658, 0x0, 0x0})
	/home/powersj/telegraf/cmd/telegraf/telegraf.go:147 +0x28a
main.run(...)
	/home/powersj/telegraf/cmd/telegraf/telegraf_posix.go:8
main.main()
	/home/powersj/telegraf/cmd/telegraf/telegraf.go:485 +0xa9a

Additional info

No response

@powersj powersj added the bug unexpected problem or unintended behavior label Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/snmp bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant