Skip to content

[input.snmp] not working/hanging #10603

@chaosenze

Description

@chaosenze

Relevant telegraf.conf

[[inputs.snmp]]
  agents = ["udp://192.168.23.239:161"]
  version = 2
  community = "public_ro"

# test collect
  [[inputs.snmp.field]]
# working until v1.21.2
    #oid = "RFC1213-MIB::sysUpTime.0"
# need to change to get working since telegraf v1.21.0
    oid = ".1.3.6.1.6.3.15.1.1.4.0"
    name = "uptime"

Logs from Telegraf

# telegraf-1.21.3/usr/bin/telegraf --config snmp.conf --test --debug
2022-02-08T00:24:45Z I! Starting Telegraf 1.21.3
2022-02-08T00:24:45Z I! Loaded inputs: snmp
2022-02-08T00:24:45Z I! Loaded aggregators: 
2022-02-08T00:24:45Z I! Loaded processors: 
2022-02-08T00:24:45Z W! Outputs are not used in testing mode!
2022-02-08T00:24:45Z I! Tags enabled: host=switch01
2022-02-08T00:24:45Z D! [agent] Initializing plugins

System info

Telegraf 1.21.3, Arch linux

Docker

No response

Steps to reproduce

I'm compleetly new and started from scratch, this is why I take it simple:

  1. downloaded latest version
  2. telegraf --usage snmp > testconfig.conf
  3. edit testconfig to below one
  4. telegraf --config testconfig.conf --test
    This was but I was not able to get it working after a few hours of testing and modifiing I try later version and my config worked.

Expected behavior

 # telegraf-1.21.2/usr/bin/telegraf --config snmp.conf --test --debug
2022-02-08T01:04:04Z I! Starting Telegraf 1.21.2
2022-02-08T01:04:04Z I! Loaded inputs: snmp
2022-02-08T01:04:04Z I! Loaded aggregators: 
2022-02-08T01:04:04Z I! Loaded processors: 
2022-02-08T01:04:04Z W! Outputs are not used in testing mode!
2022-02-08T01:04:04Z I! Tags enabled: host=arch-influxdb
2022-02-08T01:04:04Z D! [agent] Initializing plugins
2022-02-08T01:04:11Z D! [agent] Starting service inputs
2022-02-08T01:04:11Z D! [agent] Stopping service inputs
2022-02-08T01:04:11Z D! [agent] Input channel closed
> snmp,agent_host=192.168.23.239,host=arch-influxdb uptime=26i 1644282251000000000
2022-02-08T01:04:11Z D! [agent] Stopped Successfully

real    0m7.272s
user    0m7.111s
sys     0m0.896s

Actual behavior

# telegraf-1.21.3/usr/bin/telegraf --config snmp.conf --test --debug
2022-02-08T01:05:59Z I! Starting Telegraf 1.21.3
2022-02-08T01:05:59Z I! Loaded inputs: snmp
2022-02-08T01:05:59Z I! Loaded aggregators: 
2022-02-08T01:05:59Z I! Loaded processors: 
2022-02-08T01:05:59Z W! Outputs are not used in testing mode!
2022-02-08T01:05:59Z I! Tags enabled: host=arch-influxdb
2022-02-08T01:05:59Z D! [agent] Initializing plugins
^Z[1]   Killed                  telegraf-${vers}/usr/bin/telegraf --config snmp.conf --test --debug

[2]+  Stopped                 telegraf-${vers}/usr/bin/telegraf --config snmp.conf --test --debug

real    1m26.923s
user    0m0.000s
sys     0m0.002s

Additional info

As listed in Expected behavior, config is running fine with telegraf version 1.21.2

Since v1.21.0 the oid in config has to be adjusted to numbered notation to get it working:
from: oid = "RFC1213-MIB::sysUpTime.0"
to: oid = ".1.3.6.1.6.3.15.1.1.4.0"

Debug Output of version 1.20.4 with 'oid = "RFC1213-MIB::sysUpTime.0" '

# telegraf-1.20.4/usr/bin/telegraf --config snmp.conf --test --debug
2022-02-08T01:03:02Z I! Starting Telegraf 1.20.4
2022-02-08T01:03:02Z D! [agent] Initializing plugins
2022-02-08T01:03:02Z D! [agent] Starting service inputs
2022-02-08T01:03:02Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "RFC1213-MIB::sysUpTime.0"
> snmp,agent_host=192.168.23.239,host=arch-influxdb uptime=18089086i 1644282183000000000
2022-02-08T01:03:02Z D! [agent] Stopping service inputs
2022-02-08T01:03:02Z D! [agent] Input channel closed
2022-02-08T01:03:02Z D! [agent] Stopped Successfully

real    0m0.621s
user    0m0.556s
sys     0m0.217s

Also you can see, there is an large time lag.
v1.20.4: real 0m0.621s
v1.21.2: real 0m7.272s

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/snmpbugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions