influxdata / influxdata/telegraf
SNMP input: error in unmarshalResponse
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
On the server I have application with snmp interface support. Snmpwalk example:
```
[root@SOR-01 telegraf.d]# sudo -u telegraf snmpwalk -mALL -v 2c -c public 127.0.0.1:4162 1.3.6.1.4.1.20873
PROTEI-SG-DIAM-MIB::pcsmIndex.1 = INTEGER: 1
PROTEI-SG-DIAM-MIB::pcsmIndex.2 = INTEGER: 2
PROTEI-SG-DIAM-MIB::pcsmIndex.3 = INTEGER: 3
PROTEI-SG-DIAM-MIB::pcsmIndex.4 = INTEGER: 4
PROTEI-SG-DIAM-MIB::pcsmCA.1 = STRING: "Sg.DIAM.PCSM.3"
PROTEI-SG-DIAM-MIB::pcsmCA.2 = STRING: "Sg.DIAM.PCSM.2"
PROTEI-SG-DIAM-MIB::pcsmCA.3 = STRING: "Sg.DIAM.PCSM.1"
PROTEI-SG-DIAM-MIB::pcsmCA.4 = STRING: "Sg.DIAM.PCSM.0"
PROTEI-SG-DIAM-MIB::pcsmOSTATE.1 = STRING: "ACTIVATE"
PROTEI-SG-DIAM-MIB::pcsmOSTATE.2 = STRING: "ACTIVATE"
PROTEI-SG-DIAM-MIB::pcsmOSTATE.3 = STRING: "ACTIVATE"
PROTEI-SG-DIAM-MIB::pcsmOSTATE.4 = STRING: "ACTIVATE"
PROTEI-AD-OMI-MIB::ad-omi-acclIndex.1 = INTEGER: 1
PROTEI-AD-OMI-MIB::ad-omi-acclIndex.2 = INTEGER: 2
PROTEI-AD-OMI-MIB::ad-omi-acclIndex.3 = INTEGER: 3
PROTEI-AD-OMI-MIB::ad-omi-acclCA.1 = STRING: "Ad.OMI.ACCL.2"
PROTEI-AD-OMI-MIB::ad-omi-acclCA.2 = STRING: "Ad.OMI.ACCL.3"
PROTEI-AD-OMI-MIB::ad-omi-acclCA.3 = STRING: "Ad.OMI.ACCL.1"
PROTEI-AD-OMI-MIB::ad-omi-acclOSTATE.1 = STRING: "ACTIVATE"
PROTEI-AD-OMI-MIB::ad-omi-acclOSTATE.2 = STRING: "ACTIVATE"
PROTEI-AD-OMI-MIB::ad-omi-acclOSTATE.3 = STRING: "ACTIVATE"
```
And the following conf file:
```
[[inputs.snmp]]
agents = [ "127.0.0.1:4162" ]
version = 2
community = "public"
tagexclude = ["agent_host"]
[inputs.snmp.tags]
app="Protei_RG_LTE"
Metrics_type="app"
[[inputs.snmp.table]]
name = "OMI_ACCL"
inherit_tags = [ "app","Metrics_type" ]
[[inputs.snmp.table.field]]
name = "CA"
is_tag = true
oid = "PROTEI-AD-OMI-MIB::ad-omi-acclCA"
[[inputs.snmp.table.field]]
name = "state"
oid = "PROTEI-AD-OMI-MIB::ad-omi-acclOSTATE"
[[inputs.snmp.table]]
name = "OMI_ASCL"
inherit_tags = [ "app","Metrics_type" ]
[[inputs.snmp.table.field]]
name = "CA"
is_tag = true
oid = "PROTEI-AD-OMI-MIB::ad-omi-asclCA"
[[inputs.snmp.table.field]]
name = "state"
oid = "PROTEI-AD-OMI-MIB::ad-omi-asclOSTATE"
[[processors.enum]]
[[processors.enum.mapping]]
field = "state"
# default = 0
## Table of mappings
[processors.enum.mapping.value_mappings]
ACTIVATE = 1
FAIL = 0
```
At least on version 1.14.5 - everything works as expected:
```
[root@SOR-01 telegraf.d]# sudo -u telegraf telegraf --test --config Test.conf --debug
2021-10-13T10:12:12Z I! Starting Telegraf 1.14.5
2021-10-13T10:12:12Z D! [agent] Initializing plugins
2021-10-13T10:12:12Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-acclCA"
2021-10-13T10:12:12Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-acclOSTATE"
2021-10-13T10:12:12Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-asclCA"
2021-10-13T10:12:12Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-asclOSTATE"
> OMI_ACCL,CA=Ad.OMI.ACCL.3,Metrics_type=app,app=Protei_RG_LTE,host=SOR-01 state="ACTIVATE" 1634119933000000000
> OMI_ACCL,CA=Ad.OMI.ACCL.1,Metrics_type=app,app=Protei_RG_LTE,host=SOR-01 state="ACTIVATE" 1634119933000000000
> OMI_ACCL,CA=Ad.OMI.ACCL.2,Metrics_type=app,app=Protei_RG_LTE,host=SOR-01 state="ACTIVATE" 1634119933000000000
```
But on version 1.20 and the same config we've faced an error:
```
[root@SOR-02 telegraf.d]# sudo -u telegraf telegraf --test --config RG_LTE_omi.conf --debug
ERRO[0000]log.go:120 gosnowflake.(*defaultLogger).Errorf failed to create cache directory. /etc/telegraf/.cache/snowflake, err: mkdir /etc/telegraf/.cache: permission denied. ignored
ERRO[0000]log.go:120 gosnowflake.(*defaultLogger).Errorf failed to open. Ignored. open /etc/telegraf/.cache/snowflake/ocsp_response_cache.json: no such file or directory
2021-10-13T10:23:48Z I! Starting Telegraf 1.20.0
2021-10-13T10:23:48Z D! [agent] Initializing plugins
2021-10-13T10:23:48Z D! [agent] Starting service inputs
2021-10-13T10:23:48Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-acclCA"
2021-10-13T10:23:48Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-acclOSTATE"
2021-10-13T10:23:48Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-asclCA"
2021-10-13T10:23:49Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "PROTEI-AD-OMI-MIB::ad-omi-asclOSTATE"
2021-10-13T10:23:49Z E! [inputs.snmp] Error in plugin: agent 127.0.0.1:4162: gathering table OMI_ACCL: performing bulk walk for field CA: error in unmarshalResponse: error parsing OID Value: invalid OID length
2021-10-13T10:23:49Z E! [inputs.snmp] Error in plugin: agent 127.0.0.1:4162: gathering table OMI_ASCL: performing bulk walk for field CA: error in unmarshalResponse: error parsing OID Value: invalid OID length
2021-10-13T10:23:49Z D! [agent] Stopping service inputs
2021-10-13T10:23:49Z D! [agent] Input channel closed
2021-10-13T10:23:49Z D! [agent] Processor channel closed
2021-10-13T10:23:49Z D! [agent] Stopped Successfully
2021-10-13T10:23:49Z E! [telegraf] Error running agent: input plugins recorded 2 errors
```
I've checked on 1.19.3 and it works there as well. So I can only take a guess that it has something to do with new GO version implemented in 1.20
Contributor guide
Research direction
Start with the inputs.snmp table-walk path and the unmarshalResponse error reported for field CA, then review the supplied configuration and compare Telegraf 1.19.3 with 1.20. The merged pull request #10076 is relevant context. Done means the OMI_ACCL and OMI_ASCL walks complete without invalid OID errors and emit the expected CA and state metrics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devops, observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100