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 not handling error codes properly #8242

Closed
s-r-engineer opened this issue Oct 8, 2020 · 2 comments
Closed

SNMP plugin not handling error codes properly #8242

s-r-engineer opened this issue Oct 8, 2020 · 2 comments
Labels
area/snmp bug unexpected problem or unintended behavior

Comments

@s-r-engineer
Copy link

s-r-engineer commented Oct 8, 2020

Relevant telegraf.conf:

[[outputs.file]]
  files = ["stdout"]
[[inputs.snmp]]
  agents = ["udp://127.0.0.1:161"]
  version = 3
  sec_name = "USER"
  auth_protocol = "SHA"
  auth_password = "Some wrong pawwsord"
  sec_level = "authPriv"
  priv_protocol = "AES"
  priv_password = "some wrong password"
  [[inputs.snmp.field]]
    oid = "RFC1213-MIB::sysUpTime.0"
    name = "uptime"

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

System info:

Not relevant here

Docker

Steps to reproduce:

  1. Start a proper snmpd v3 with authPriv user
  2. try to run telegraf
  3. profit!!!!1

Expected behavior:

To not to send to output any metrics if there is some problem with authentication or encryption

Actual behavior:

Currently if you are sending an improper SNMPv3 request (like wrong password) you will receive one of special OIDs which is in fact a error message.

Example:

Server config:
snmp user: user
snmp auth protocol: sha
snmp user auth pass: foobaaaaaaar

Telegraf config shown above.
Results here:

if pkt, err := gs.Get([]string{oid}); err != nil {

And OID in ent will be not the same you sent but one of predefined error oids. And telegraf will not threat it like error. It will SEND TO OUTPUT WRONG DATA like it is a proper data

Additional info:

Solution is to check that oid in answer is the requested one

@s-r-engineer s-r-engineer added the bug unexpected problem or unintended behavior label Oct 8, 2020
@ssoroka ssoroka changed the title Telegraf returning wrong values SNMP plugin not handling error codes properly Oct 8, 2020
@s-r-engineer
Copy link
Author

Totally forgot. Here is the place in code where mentioned that we need to handle that on our own https://github.com/soniah/gosnmp/blob/37eb72902fd19f4c25acdb06f95e07c59b90f363/marshal.go#L279

@Hipska
Copy link
Contributor

Hipska commented Feb 16, 2021

Duplicates #7929

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

3 participants