Begginer question - SNMP Plugin - How to translate OID when is a tag value

Hi!

I´m sure I read somewhere how to do it, but I couldn’t find it now.

My problem is this:

This is my tag,

  [[inputs.snmp.field]]
    oid = ".1.3.6.1.2.1.1.2.0"
    name = "SNMPv2-MIB::sysObjectID"
    is_tag = true

This is an example output:
SNMPv2-MIB::system,SNMPv2-MIB::sysLocation=XXXXX,SNMPv2-MIB::sysName=XXXXXX,SNMPv2-MIB::sysObjectID=.1.3.6.1.4.1.2011.2.239.57, IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12455972.26 1720620327000000000

I should like to have SysObjectID translated like this:

SNMPv2-MIB::sysObjectID.0 = OID: HUAWEI-MIB::ce6857-48S6CQ-EI

As far as I could check is not an ENUM option.

Thanks!!

      ## Specifies if the value of given field should be snmptranslated
      ## by default no field values are translated
      # translate = true

Thanks @Hipska!

I added the line here:

  [[inputs.snmp.field]]
    oid = ".1.3.6.1.2.1.1.2.0"
    name = "SNMPv2-MIB::sysObjectID"
    translate = true
    is_tag = true

But it didn’t work.

 SNMPv2-MIB::system,SNMPv2-MIB::sysLocation=XXXXX,SNMPv2-MIB::sysName=XXXXXX,SNMPv2-MIB::sysObjectID=.1.3.6.1.4.1.2011.2.239.57 IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12469396.22 1720633751000000000

I checked that the OID is translatable:

[Server]$ snmptranslate .1.3.6.1.4.1.2011.2.239.57
HUAWEI-MIB::ce6857-48S6CQ-EI

I´m running Telegraf 1.30.3

The documentation puts the line in a inputs.snmp.table.field section.
I used it in a inputs.snmp.field section.
But I suppose it applies to both!

Regards!

What snmp translator do you use? And do you have any debug output when using this field definition?

  [[inputs.snmp.field]]
    oid = "SNMPv2-MIB::sysObjectID"
    translate = true
    is_tag = true

Hi!

I set gosmi as snmp translator:

  ## Method of translating SNMP objects. Can be "netsnmp" (deprecated) which
  ## translates by calling external programs snmptranslate and snmptable,
  ## or "gosmi" which translates using the built-in gosmi library.
  # snmp_translator = "netsnmp"
  snmp_translator = "gosmi"

This is the output with --debug

[SERVER]$ telegraf --config telegraf.cfg --config-directory /test/ --debug --test
2024-07-11T11:00:34Z I! Loading config: telegraf.cfg
2024-07-11T11:00:34Z I! Loading config: /test/INPUTS_SNMPv2-MIB.conf
2024-07-11T11:00:34Z I! Starting Telegraf 1.30.3 brought to you by InfluxData the makers of InfluxDB
2024-07-11T11:00:34Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-07-11T11:00:34Z I! Loaded inputs: snmp (4x)
2024-07-11T11:00:34Z I! Loaded aggregators:
2024-07-11T11:00:34Z I! Loaded processors:
2024-07-11T11:00:34Z I! Loaded secretstores:
2024-07-11T11:00:34Z W! Outputs are not used in testing mode!
2024-07-11T11:00:34Z I! Tags enabled:
2024-07-11T11:00:34Z D! [agent] Initializing plugins
2024-07-11T11:00:47Z D! [agent] Starting service inputs
> SNMPv2-MIB::system,SNMPv2-MIB::sysContact=Backend,SNMPv2-MIB::sysDescr=Huawei,SNMPv2-MIB::sysLocation=S,SNMPv2-MIB::sysName=A,SNMPv2-MIB::sysObjectID=.1.3.6.1.4.1.2011.2.239.57,source=172.nn.nn.nn IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12531292.2 1720695648000000000
2024-07-11T11:00:48Z D! [agent] Stopping service inputs
2024-07-11T11:00:48Z D! [agent] Input channel closed
2024-07-11T11:00:48Z D! [agent] Stopped Successfully

No clue there, as far as I can see.

Hmm, it doesn’t look like you used my exact field snippet… I deliberately left out name and put the translated name in oid.

Sorry, didn’t pay attention to that!
I pasted your snippet into my conf
Here is the output:

[pdfraire@arys test]$ telegraf --config /telegraf.cfg --config-directory /test/ --debug --test
2024-07-11T11:43:04Z I! Loading config: /telegraf.cfg
2024-07-11T11:43:04Z I! Loading config: /test/INPUTS_SNMPv2-MIB.conf
2024-07-11T11:43:04Z I! Starting Telegraf 1.30.3 brought to you by InfluxData the makers of InfluxDB
2024-07-11T11:43:04Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-07-11T11:43:04Z I! Loaded inputs: snmp
2024-07-11T11:43:04Z I! Loaded aggregators:
2024-07-11T11:43:04Z I! Loaded processors:
2024-07-11T11:43:04Z I! Loaded secretstores:
2024-07-11T11:43:04Z W! Outputs are not used in testing mode!
2024-07-11T11:43:04Z I! Tags enabled:
2024-07-11T11:43:04Z D! [agent] Initializing plugins
2024-07-11T11:43:16Z D! [agent] Starting service inputs
2024-07-11T11:43:16Z D! [agent] Stopping service inputs
2024-07-11T11:43:16Z D! [agent] Input channel closed
2024-07-11T11:43:16Z D! [agent] Stopped Successfully
> SNMPv2-MIB::system,SNMPv2-MIB::sysContact=X,SNMPv2-MIB::sysDescr=X,SNMPv2-MIB::sysLocation=X,SNMPv2-MIB::sysName=X,source=172.18.35.21 IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12533841.56 1720698197000000000

The field is not in the line.

These are my config first lines:

[[inputs.snmp]]
  agents = ["udp://xxxxx"]

  #timeout = "5s"
  version = 2
  community = "xxxxx"
  #retries = 3
  #max_repetitions = 10
  #interval = "24h"
  interval = "5m"
  agent_host_tag = "source"

  name = "SNMPv2-MIB::system"

  [[inputs.snmp.field]]
    # "A textual description of the entity. This value should\n include the full name and version identification of\n the system\'s hardware type, software operating-system,\n and networking software."
    oid = ".1.3.6.1.2.1.1.1.0"
    name = "SNMPv2-MIB::sysDescr"
    is_tag = true

  [[inputs.snmp.field]]
    oid = "SNMPv2-MIB::sysObjectID"
    translate = true
    is_tag = true


I did another test using the translated oid in Descr field, , and it also disappeared from output.
Should I remove the snmp_translator = “gosmi” line form config?

I removed the gosmi

2024-07-11T11:59:15Z I! Loading config: telegraf.cfg
2024-07-11T11:59:15Z W! DeprecationWarning: Value "netsnmp" for option "snmp_translator" of plugin "agent" deprecated since version 1.25.0 and will be removed in 2.0.0: Use 'gosmi' instead
2024-07-11T11:59:15Z I! Loading config: INPUTS_SNMPv2-MIB.conf
2024-07-11T11:59:15Z W! DeprecationWarning: Value "netsnmp" for option "snmp_translator" of plugin "agent" deprecated since version 1.25.0 and will be removed in 2.0.0: Use 'gosmi' instead
2024-07-11T11:59:15Z I! Starting Telegraf 1.30.3 brought to you by InfluxData the makers of InfluxDB
2024-07-11T11:59:15Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-07-11T11:59:15Z I! Loaded inputs: snmp
2024-07-11T11:59:15Z I! Loaded aggregators:
2024-07-11T11:59:15Z I! Loaded processors:
2024-07-11T11:59:15Z I! Loaded secretstores:
2024-07-11T11:59:15Z W! Outputs are not used in testing mode!
2024-07-11T11:59:15Z I! Tags enabled:
2024-07-11T11:59:15Z D! [agent] Initializing plugins
2024-07-11T11:59:15Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "SNMPv2-MIB::sysDescr"
2024-07-11T11:59:15Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "SNMPv2-MIB::sysObjectID"
2024-07-11T11:59:16Z D! [agent] Starting service inputs
2024-07-11T11:59:16Z D! [agent] Stopping service inputs
2024-07-11T11:59:16Z D! [agent] Input channel closed
2024-07-11T11:59:16Z D! [agent] Stopped Successfully
> SNMPv2-MIB::system,SNMPv2-MIB::sysContact=X,SNMPv2-MIB::sysLocation=X,SNMPv2-MIB::sysName=X,source=172.xx.xx.xx IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12534800.9 1720699156000000000

[server]$ "snmptranslate" "-Td" "-Ob" "SNMPv2-MIB::sysDescr"
SNMPv2-MIB::sysDescr
sysDescr OBJECT-TYPE
  -- FROM       SNMPv2-MIB, RFC1213-MIB, NIOBE-MIB
  -- TEXTUAL CONVENTION DisplayString
  SYNTAX        OCTET STRING (0..255)
  DISPLAY-HINT  "255a"
  MAX-ACCESS    read-only
  STATUS        current
  DESCRIPTION   "A textual description of the entity.  This value should
            include the full name and version identification of
            the system's hardware type, software operating-system,
           and networking software."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) 1 }
[server]$ "snmptranslate" "-Td" "-Ob" "SNMPv2-MIB::sysObjectID"
SNMPv2-MIB::sysObjectID
sysObjectID OBJECT-TYPE
  -- FROM       SNMPv2-MIB, RFC1213-MIB, NIOBE-MIB
  SYNTAX        OBJECT IDENTIFIER
  MAX-ACCESS    read-only
  STATUS        current
  DESCRIPTION   "The vendor's authoritative identification of the
            network management subsystem contained in the entity.
            This value is allocated within the SMI enterprises
            subtree (1.3.6.1.4.1) and provides an easy and
            unambiguous means for determining `what kind of box' is
            being managed.  For example, if vendor `Flintstones,
            Inc.' was assigned the subtree 1.3.6.1.4.1.424242,
            it could assign the identifier 1.3.6.1.4.1.424242.1.1
            to its `Fred Router'."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) 2 }

Both fields are still missing from output

Sorry, it should have been this:

  [[inputs.snmp.field]]
    oid = "SNMPv2-MIB::sysObjectID.0"
    translate = true
    is_tag = true

Also, you should only have 1 [agent] section in all your configs.

Yes, I have only one [agent] section in my main telegraf.conf

With the .0 added I got back the fields, but still no translation either with gosmi or snmptranslate

[server test]$ telegraf --config telegraf.cfg --config-directory /test/ --debug --test
2024-07-11T12:06:17Z I! Loading config: telegraf.cfg
2024-07-11T12:06:17Z I! Loading config: /test/INPUTS_SNMPv2-MIB.conf
2024-07-11T12:06:17Z I! Starting Telegraf 1.30.3 brought to you by InfluxData the makers of InfluxDB
2024-07-11T12:06:17Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-07-11T12:06:17Z I! Loaded inputs: snmp
2024-07-11T12:06:17Z I! Loaded aggregators:
2024-07-11T12:06:17Z I! Loaded processors:
2024-07-11T12:06:17Z I! Loaded secretstores:
2024-07-11T12:06:17Z W! Outputs are not used in testing mode!
2024-07-11T12:06:17Z I! Tags enabled:
2024-07-11T12:06:17Z D! [agent] Initializing plugins
2024-07-11T12:06:30Z D! [agent] Starting service inputs
2024-07-11T12:06:30Z D! [agent] Stopping service inputs
2024-07-11T12:06:30Z D! [agent] Input channel closed
2024-07-11T12:06:30Z D! [agent] Stopped Successfully
> SNMPv2-MIB::system,SNMPv2-MIB::sysContact=X,SNMPv2-MIB::sysLocation=X,SNMPv2-MIB::sysName=X,source=172.18.35.21,sysDescr.0=X,sysObjectID.0=.1.3.6.1.4.1.2011.2.239.57 IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12535234.94 1720699590000000000
[server test]$ telegraf --config /test/telegraf.cfg --config-directory /test/ --debug --test
2024-07-11T12:08:22Z I! Loading config: /test/telegraf.cfg
2024-07-11T12:08:22Z W! DeprecationWarning: Value "netsnmp" for option "snmp_translator" of plugin "agent" deprecated since version 1.25.0 and will be removed in 2.0.0: Use 'gosmi' instead
2024-07-11T12:08:22Z I! Loading config: /test/INPUTS_SNMPv2-MIB.conf
2024-07-11T12:08:22Z W! DeprecationWarning: Value "netsnmp" for option "snmp_translator" of plugin "agent" deprecated since version 1.25.0 and will be removed in 2.0.0: Use 'gosmi' instead
2024-07-11T12:08:22Z I! Starting Telegraf 1.30.3 brought to you by InfluxData the makers of InfluxDB
2024-07-11T12:08:22Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-07-11T12:08:22Z I! Loaded inputs: snmp
2024-07-11T12:08:22Z I! Loaded aggregators:
2024-07-11T12:08:22Z I! Loaded processors:
2024-07-11T12:08:22Z I! Loaded secretstores:
2024-07-11T12:08:22Z W! Outputs are not used in testing mode!
2024-07-11T12:08:22Z I! Tags enabled:
2024-07-11T12:08:22Z D! [agent] Initializing plugins
2024-07-11T12:08:22Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "SNMPv2-MIB::sysDescr.0"
2024-07-11T12:08:22Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "SNMPv2-MIB::sysObjectID.0"
2024-07-11T12:08:23Z D! [agent] Starting service inputs
2024-07-11T12:08:23Z D! [agent] Stopping service inputs
2024-07-11T12:08:23Z D! [agent] Input channel closed
2024-07-11T12:08:23Z D! [agent] Stopped Successfully
> SNMPv2-MIB::system,SNMPv2-MIB::sysContact=X,SNMPv2-MIB::sysLocation=X,SNMPv2-MIB::sysName=X,source=172.18.35.21,sysDescr.0=X,sysObjectID.0=.1.3.6.1.4.1.2011.2.239.57 IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12535347.95 1720699703000000000

Okay, it feels strange to also have the DeprecationWarning when loading the second config file…

Anyway, could you also try when the field is not a tag?

  [[inputs.snmp.field]]
    oid = "SNMPv2-MIB::sysObjectID.0"
    translate = true
    is_tag = false

Same result, but in field set section of line

> SNMPv2-MIB::system,SNMPv2-MIB::sysContact=X,SNMPv2-MIB::sysLocation=X,SNMPv2-MIB::sysName=X,source=172.18.35.21,sysDescr.0=X IF-MIB::ifNumber=60i,SNMPv2-MIB::sysUpTime=12538720.88,sysObjectID.0=".1.3.6.1.4.1.2011.2.239.57" 1720703076000000000

I tried both translators.

Okay, looks like the translate option isn’t working anymore. Could you create a bug report here?

Done: