Incorrect value for SNMP bits field
Relevant telegraf.conf
[[inputs.snmp]]
name_override = "snmp_barco_projector"
path = ["../mibs"]
agents = ["10.91.77.132"]
version = 2
community = "public"
agent_host_tag = "source"
[[inputs.snmp.field]]
oid = 'BARCO-ME-DCP-MIB::lampMode.0'
conversion = 'float'
Logs from Telegraf
$ telegraf --config experiments/telegraf_debug.conf --test --debug
2024-02-07T02:33:00Z I! Loading config: experiments/telegraf_debug.conf
2024-02-07T02:33:00Z I! Starting Telegraf 1.29.2 brought to you by InfluxData the makers of InfluxDB
2024-02-07T02:33:00Z I! Available plugins: 241 inputs, 9 aggregators, 30 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-02-07T02:33:00Z I! Loaded inputs: snmp
2024-02-07T02:33:00Z I! Loaded aggregators:
2024-02-07T02:33:00Z I! Loaded processors:
2024-02-07T02:33:00Z I! Loaded secretstores:
2024-02-07T02:33:00Z W! Outputs are not used in testing mode!
2024-02-07T02:33:00Z I! Tags enabled:
2024-02-07T02:33:00Z D! [agent] Initializing plugins
2024-02-07T02:33:01Z D! [agent] Starting service inputs
2024-02-07T02:33:01Z D! [agent] Stopping service inputs
2024-02-07T02:33:01Z D! [agent] Input channel closed
2024-02-07T02:33:01Z D! [agent] Stopped Successfully
> snmp_barco_projector,source=10.91.77.132 lampMode=0 1707273181000000000
System info
Telegraf 1.29.2, Ubuntu 22.04
Docker
No response
Steps to reproduce
...
Expected behavior
The value should be 7 as shown in snmpget
$ snmpget -v2c -c public -m BARCO-ME-DCP-MIB 10.91.77.132 lampMode.0
BARCO-ME-DCP-MIB::lampMode.0 = BITS: 01 cloON(7)
Actual behavior
With conversion to float, the value becomes 0:
> snmp_barco_projector,source=10.91.77.132 lampMode=0 1707273181000000000
Without that conversion, the value is empty string:
> snmp_barco_projector,source=10.91.77.132 lampMode.0="" 1707273059000000000
Additional info
This OID is a BITS type. Here's the relevant section from BARCO-ME-DCP-MIB.mib.txt
-- 1.3.6.1.4.1.12612.220.11.2.2.4.4
lampMode OBJECT-TYPE
SYNTAX BITS
{
unused(0),
cloON(7)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This is the lamp mode.
cloON: Constant Light Output active"
::= { lampProperties 4 }
I also tried specifying the OID numerically instead of the name, and the result is the same.
I just realized it works withconversion='enum' and the result is a string:
> snmp_barco_projector,source=10.91.77.132 lampMode="cloON" 1707273508000000000
But that's more difficult to track as a metric. Is there a way to get just the number? With conversion='enum(1)' I get both:
> snmp_barco_projector,source=10.91.77.132 lampMode="cloON(7)" 1707273517000000000
What do yo get with conversion mode int?
It's still the wrong number, lampMode=0i
Bummer, looks like enum is the way to go then.
what output are you using? For example, InfluxDB supports string fields.
Looking through this again, was there anything for telegraf to do here? It appears this was due to the way the value is returned and possible additional processing was required?
I'm sending metrics to Prometheus, so I can't use string fields.
You're right, I can use processors.enum to convert the string to numbers. But I still think it's a bug in the Telegraf input plugin; the conversion to int should use the correct number instead of 0.
Can you show the output of the following command?
snmpget -Oe -v2c -c public -m BARCO-ME-DCP-MIB 10.91.77.132 lampMode.0
I believe there's something wrong with the data from the device as well..
Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Forums or provide additional details in this issue and reqeust that it be re-opened. Thank you!
Sorry I missed this message. Here's the requested output:
% snmpget -Oe -v2c -c public -m BARCO-ME-DCP-MIB 10.91.77.132 lampMode.0
BARCO-ME-DCP-MIB::lampMode.0 = BITS: 01 7