Help with config

#1

Hello all,

I am sure I am overlooking a small detail but for some reason as soon as I add the section below to my configuration the service fails to start.

   # Interface tag - used to identify interface in metrics database
  [[inputs.snmp.table.field]]
  name = "ifDescr"
  oid = "IF-MIB::ifDescr.1"

Here’s my complete working config:

[[inputs.snmp]]

agents = [ "192.168.139.50:161" ]
#   ## Timeout for each SNMP query.
   timeout = "5s"
#   ## Number of retries to attempt within timeout.
   retries = 3
#   ## SNMP version, values can be 1, 2, or 3
   version = 2
#   
#   ## SNMP community string.
   community = "public"
#
#   ## The GETBULK max-repetitions parameter
   max_repetitions = 10
#
#   ## measurement name
   name = "unifi_UAP"
   [[inputs.snmp.field]]
     name = "sysUpTime"
     oid = ".1.3.6.1.4.1.41112.1.6.3.5.0"

Error:

● telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
   Loaded: loaded (/lib/systemd/system/telegraf.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Mon 2018-04-16 16:03:24 EDT; 361ms ago
     Docs: https://github.com/influxdata/telegraf
  Process: 14049 ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS (code=exited, status=1/FAILURE)
 Main PID: 14049 (code=exited, status=1/FAILURE)

Apr 16 16:03:24 ubuntustats systemd[1]: telegraf.service: Main process exited, code=exited, status=1/FAILURE
Apr 16 16:03:24 ubuntustats systemd[1]: telegraf.service: Unit entered failed state.
Apr 16 16:03:24 ubuntustats systemd[1]: telegraf.service: Failed with result 'exit-code'.
Apr 16 16:03:24 ubuntustats systemd[1]: telegraf.service: Service hold-off time over, scheduling restart.
Apr 16 16:03:24 ubuntustats systemd[1]: Stopped The plugin-driven server agent for reporting metrics into InfluxDB.
Apr 16 16:03:24 ubuntustats systemd[1]: telegraf.service: Start request repeated too quickly.
Apr 16 16:03:24 ubuntustats systemd[1]: Failed to start The plugin-driven server agent for reporting metrics into InfluxDB.

What I am doing wrong?

#2

I think maybe you just need inputs.snmp.table before the table field:

[[inputs.snmp.table]]
  [[inputs.snmp.table.field]]
  name = "ifDescr"
  oid = "IF-MIB::ifDescr.1"

If that doesn’t help, can you post the full non-working section for the snmp input.

#3

@daniel That helped and now the service will start. Unfortunately I am greeted with:

Error in plugin [inputs.snmp]: initializing table unifi: initializing field ifDescr: translating: exec: "snmptranslate": executable file not found in $PATH
#4

When using OID textual names, you will need the snmptranslate and snmptable commands in your environment. Usually you can get these with apt-get install snmp.

#5

@daniel I tried installing what you suggested but I still get the same error.

#6

Check if these commands exist for the telegraf user:

sudo -u telegraf snmptranslate --help
#7

@daniel It does not exist (command not found). Shouldn’t it been installed with snmp?

#8

Is it listed in the output of dpkg -L snmp

#9

Let me try and explain better (should of done that since the beginning, I apologize).

Here’s is my working configuration prior to the error:

[[inputs.snmp]]

agents = [ "IP:161" ]
#   ## Timeout for each SNMP query.
   timeout = "5s"
#   ## Number of retries to attempt within timeout.
   retries = 3
#   ## SNMP version, values can be 1, 2, or 3
   version = 2
#
#   ## SNMP community string.
   community = "Public"
#
#   ## The GETBULK max-repetitions parameter
   max_repetitions = 10
   
name = "esxi"
[[inputs.snmp.field]]
  name = "esxi-memory-used"
  oid = ".1.3.6.1.2.1.25.2.3.1.6.5"
[[inputs.snmp.field]]
  name = "esxi-memory-available"
  oid = ".1.3.6.1.2.1.25.2.2.0"
[[inputs.snmp.field]]
  name = "esxi-uptime"
  oid = ".1.3.6.1.2.1.25.1.1.0"
[[inputs.snmp.field]]
  name = "esxi-cpuload1"
  oid = ".1.3.6.1.2.1.25.3.3.1.2.1"
[[inputs.snmp.field]]
  name = "esxi-cpuload2"
  oid = "..1.3.6.1.2.1.25.3.3.1.2.2"
[[inputs.snmp.field]]
  name = "esxi-cpuload3"
  oid = ".1.3.6.1.2.1.25.3.3.1.2.3"
[[inputs.snmp.field]]
  name = "esxi-cpuload4"
  oid = ".1.3.6.1.2.1.25.3.3.1.2.4"
[[inputs.snmp.field]]
  name = "esxi-cpuload5"
  oid = ".1.3.6.1.2.1.25.3.3.1.2.5"
[[inputs.snmp.field]]
  name = "esxi-cpuload6"
  oid = ".1.3.6.1.2.1.25.3.3.1.2.6"

Then, I tried adding another configuration for my router:

[[inputs.snmp]]

agents = [ "IP:161" ]
#   ## Timeout for each SNMP query.
   timeout = "5s"
#   ## Number of retries to attempt within timeout.
   retries = 3
#   ## SNMP version, values can be 1, 2, or 3
   version = 1
#
#   ## SNMP community string.
   community = "Public"
#
#   ## The GETBULK max-repetitions parameter
   max_repetitions = 10
#
[[inputs.snmp.field]]
  name = "hostname"
  oid = "RFC1213-MIB::sysName.0"
  is_tag = true

[[inputs.snmp.table]]
  name = "snmp"
  inherit_tags = [ "hostname" ]

[[inputs.snmp.table.field]]
  name = "ifDescr"
  oid = "IF-MIB::ifDescr"
  is_tag = true

[[inputs.snmp.table.field]]
  name = "ifInOctets"
  oid = "IF-MIB::ifInOctets"

[[inputs.snmp.table.field]]
  name = "ifOutOctets"
  oid = "IF-MIB::ifOutOctets"

But that results in the error I originally posted. You suggested I install snmp and after doing so I get this when I try the command telegraf snmptranslate --help:

telegraf snmptranslate --help
2018/04/17 14:53:13 I! Using config file: /etc/telegraf/telegraf.conf
2018-04-17T18:53:13Z I! Starting Telegraf v1.5.3
2018-04-17T18:53:13Z I! Loaded outputs: influxdb
2018-04-17T18:53:13Z I! Loaded inputs: inputs.cpu inputs.mem inputs.net inputs.snmp inputs.snmp inputs.swap inputs.system inputs.ipmi_sensor inputs.disk inputs.diskio inputs.kernel inputs.processes
2018-04-17T18:53:13Z I! Tags enabled: host=ubuntustats
2018-04-17T18:53:13Z I! Agent Config: Interval:10s, Quiet:false, Hostname:"ubuntustats", Flush Interval:10s 
2018-04-17T18:53:22Z E! Error in plugin [inputs.snmp]: initializing field esxi-cpuload2: translating: exit status 2: Bad operator (INTEGER): At line 73 in /usr/share/mibs/ietf/SNMPv2-PDU
Unlinked OID in IPATM-IPMC-MIB: marsMIB ::= { mib-2 57 }
Undefined identifier: mib-2 near line 18 of /usr/share/mibs/ietf/IPATM-IPMC-MIB
Expected "::=" (RFC5644): At line 493 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Expected "{" (EOF): At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Bad object identifier: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Bad parse of OBJECT-IDENTITY: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
..1.3.6.1.2.1.25.3.3.1.2.2: Unknown Object Identifier (Sub-id not found: (top) -> )
2018-04-17T18:53:30Z E! Error in plugin [inputs.snmp]: initializing field esxi-cpuload2: translating: exit status 2: Bad operator (INTEGER): At line 73 in /usr/share/mibs/ietf/SNMPv2-PDU

Thanks for your help so far.

#10

In the original config, there is a line: oid = "..1.3.6.1.2.1.25.3.3.1.2.2", can you remove one of the leading dots so you have oid = ".1.3.6.1.2.1.25.3.3.1.2.2".

1 Like
#11

Ok, now I get:

Apr 17 16:32:48 ubuntustats telegraf[29556]: 2018-04-17T20:32:48Z I! Loaded outputs: influxdb
Apr 17 16:32:48 ubuntustats telegraf[29556]: 2018-04-17T20:32:48Z I! Loaded inputs: inputs.mem inputs.swap inputs.system inputs.net inputs.snmp inputs.snmp inputs.snmp inputs.cpu in
Apr 17 16:32:48 ubuntustats telegraf[29556]: 2018-04-17T20:32:48Z I! Tags enabled: host=ubuntustats
Apr 17 16:32:48 ubuntustats telegraf[29556]: 2018-04-17T20:32:48Z I! Agent Config: Interval:10s, Quiet:false, Hostname:"ubuntustats", Flush Interval:10s
Apr 17 16:32:50 ubuntustats telegraf[29556]: 2018-04-17T20:32:50Z E! Error in plugin [inputs.snmp]: initializing table : translating: exit status 2: MIB search path: /etc/telegraf/.
Apr 17 16:32:50 ubuntustats telegraf[29556]: Cannot find module (HOST-RESOURCES-MIB): At line 1 in (none)
Apr 17 16:32:50 ubuntustats telegraf[29556]: HOST-RESOURCES-MIB::hrDeviceTable: Unknown Object Identifier
Apr 17 16:33:50 ubuntustats telegraf[29556]: 2018-04-17T20:33:50Z E! Error in plugin [inputs.snmp]: initializing table : translating: exit status 2: MIB search path: /etc/telegraf/.
Apr 17 16:33:50 ubuntustats telegraf[29556]: Cannot find module (HOST-RESOURCES-MIB): At line 1 in (none)
Apr 17 16:33:50 ubuntustats telegraf[29556]: HOST-RESOURCES-MIB::hrDeviceTable: Unknown Object Identifier
#12

@daniel After a quick google search, I discovered that I needed to sudo apt-get install snmp-mibs-downloader and sudo download-mibs. I am sure you were about to tell me to do that anyways! :+1:

Now everything works great!

Thank you very much for your prompt responses. I really appreciate it!

#13

Cool, I didn’t know about that step. We did it!

#14

Hi, I have the same problem.

I am trying to collect snmp data from several sources using Telegraf
however I am getting the same error

When I try to install snmp-mibs-downloader it keeps telling me the package is not available. I have tried adding to the sources.list and updating but nothing works.

I am running ubuntu 17.04 -386i

Any Ideas!

Thanks

#15

This package is only in the non-free section of the Debian repo, perhaps you need to enable it? Here is a Debian example but it should be pretty similar:

deb http://ftp.us.debian.org/debian/ stretch main contrib non-free
#16

Thanks for the input. Sorry but your solution didn’t work. However I have solved the problem and Telegraf is now up and running. Just in case anyone else has the same issue this is what I did (not an elegant solution but it worked!).

I am using an old small form factor 32bit machine as its only job is telegraf.

1/ Went back to ubuntu 16.04 -i386 installed and fully updated.
2/ Found snmp-mibs-downloader_1.2_all.deb installed it manually and updated the MIBs files.
3/ Found snmp_5.7.2_dfsg-8.1 ubuntu3.3_i386.deb and installed it manually.
4/ Installed Influx repository and Telegraf.
5/ update telegraf.conf and restarted.

Not elegant but it worked!