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:
## 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
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 }