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

panic when using snmp in v1.21.3 #10593

Closed
ptxmac opened this issue Feb 6, 2022 · 4 comments
Closed

panic when using snmp in v1.21.3 #10593

ptxmac opened this issue Feb 6, 2022 · 4 comments
Labels
area/snmp bug unexpected problem or unintended behavior

Comments

@ptxmac
Copy link

ptxmac commented Feb 6, 2022

Relevant telegraf.conf

[[inputs.snmp]]
  agents = [ "tcp://<hidden>"]

  timeout = "30s"

  version = 2

  community = "public"

  [[inputs.snmp.field]]
    oid = "RFC1213-MIB::sysUpTime.0"
    name = "uptime"

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

  [[inputs.snmp.table]]
    oid = "UCD-SNMP-MIB::laTable"

  [[inputs.snmp.table.field]]
    oid = "UCD-SNMP-MIB::laNames"
    is_tag = true

Logs from Telegraf

2022-02-06T11:29:50Z D! [agent] Initializing plugins
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x2c77238]

goroutine 1 [running]:
github.com/influxdata/telegraf/internal/snmp.LoadMibsFromPath.func2({0xc000cdf7c0, 0x42}, {0x0, 0x0}, {0xc000c575d8, 0x2c76aa0})
	/go/src/github.com/influxdata/telegraf/internal/snmp/translate.go:86 +0x38
path/filepath.Walk({0xc000cdf7c0, 0x42}, 0xc000c575d8)
	/usr/local/go/src/path/filepath/path.go:503 +0x50
github.com/influxdata/telegraf/internal/snmp.LoadMibsFromPath({0xc0002722b0, 0x1, 0xc000c576c8}, {0x595c650, 0xc000bda5d0})
	/go/src/github.com/influxdata/telegraf/internal/snmp/translate.go:84 +0x4b7
github.com/influxdata/telegraf/plugins/inputs/snmp.(*Snmp).Init(0xc0003e4f20)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:103 +0x50
github.com/influxdata/telegraf/models.(*RunningInput).Init(0xc000c57758)
	/go/src/github.com/influxdata/telegraf/models/running_input.go:82 +0x35
github.com/influxdata/telegraf/agent.(*Agent).initPlugins(0xc000482768)
	/go/src/github.com/influxdata/telegraf/agent/agent.go:189 +0x96
github.com/influxdata/telegraf/agent.(*Agent).Run(0xc000482768, {0x58f2a08, 0xc000d0a880})
	/go/src/github.com/influxdata/telegraf/agent/agent.go:105 +0x185
main.runAgent({0x58f2a08, 0xc000d0a880}, {0x84daa60, 0x0, 0x0}, {0x84daa60, 0x0, 0x0})
	/go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf.go:312 +0xc69
main.reloadLoop({0x84daa60, 0x0, 0x0}, {0x84daa60, 0x0, 0x0})
	/go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf.go:147 +0x28a
main.run(...)
	/go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf_posix.go:8
main.main()
	/go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf.go:485 +0xa9a

System info

telegraf v1.21.3, docker v20.10.3

Docker

Extra mibs are added using apt-get install snmp-mibs-downloader

Dockerfile:

FROM telegraf:1.21.3

# Add deps
RUN sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list && \
    DEBIAN_FRONTEND=noninteractive apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends snmp-mibs-downloader && \
    rm -rf /var/lib/apt/lists/* 
RUN sed -i -e's/mibs /# mibs/g' /etc/snmp/snmp.conf    

Steps to reproduce

  1. Build above Dockerfile and use provided telegraf.conf
  2. Start telegraf
  3. BOOM

Expected behavior

Telegraf should work just as it did in v1.20.3 - i.e. read the extra MIBS and collect the metrics

Actual behavior

Telegraf crash on start

Additional info

No response

@ptxmac ptxmac added the bug unexpected problem or unintended behavior label Feb 6, 2022
@MyaLongmire
Copy link
Contributor

MyaLongmire commented Feb 7, 2022

Are you specifying the path where your mibs are stored after you download them? Try adding path = ["/your/path/here"] under version in your config file.

@ptxmac
Copy link
Author

ptxmac commented Feb 7, 2022

Are you specifying the path where your mibs are stored after you download them? Try adding path = ["/your/path/here"] under version in your config file.

That did help me to track the problem down - The crash happens when the mibs path contains a broken symlink. (I run telegraf in docker, and some of the mibs are mounted from the host)

The broken link is a user error, but the previous version of telegraf handled this gracefully instead of crashing

@MyaLongmire
Copy link
Contributor

There is a pr being worked on to check symlinks better and fail more gracefully. Please be patient as we work out all the kinks :)

I'm glad you figured out your issue!

@MyaLongmire
Copy link
Contributor

MyaLongmire commented Feb 7, 2022

Sorry I closed this a little fast without more info. Here is the pr that checks symlinks if you want to give it a go or keep an eye out on its progress!

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

No branches or pull requests

2 participants