SNMP input returnuing string values

hi everybody

i have a telegraph agent for pulling API and SNMP data from my network device.
lately, I’ve started monitoring my DHCP clusters.
one of the OIDs is cluster status, but this query gets a string as a value ( “Normal / Normal”).

using telegraf --test --config, returns only the int values.
so I assume telegraf doesn’t accept “string values” but on the other hand, it does accept the sysname and sysdes values that are string as well.

any idea what is wrong here?
how could I solve this? maybe translating it to integer?
for example Normal == 1 , not sync == 2 , down == 3.

thanks

That is how snmp works, the value you receive is the integer, but then you need to instruct telegraf to translate them. Currently, telegraf cannot do this automatically.

See this comment for an example.

but what if the value is string? (see the snmpwalk output)
could this mapping translate string to integer?

thanks

root@lab-proxy:~# snmpwalk -v2c -c XXXXX10.1.0.2 SNMPv2-SMI::enterprises.1625.2.3.1.4.1.6.0
SNMPv2-SMI::enterprises.1625.2.3.1.4.1.6.0 = STRING: “Normal / Normal”

Oh, I read it wrong. In that case there should be no problem. Could you show the config for that field? And what you get of output with —test

thanks

this is my config, i’ve bolded the specific filed.

[[inputs.snmp]]
  agents = ["udp://10.1.0.2:161"]
  version = 2
  community = "XXXXX"


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

  [[inputs.snmp.field]]
    name = "hostname"
    oid = "RFC1213-MIB::sysName.0"
    is_tag = true

  [[inputs.snmp.field]]
    name = "diskstat"
    oid = ".1.3.6.1.4.1.2021.9.1.9.1"

  [[inputs.snmp.field]]
    name = "5minload"
    oid = ".1.3.6.1.4.1.2021.10.1.3.2"


  **[[inputs.snmp.field]]**
**    name = "fp"**
**    oid = "1.3.6.1.4.1.1625.2.3.1.4.1.6"**



–test output:

> snmp,agent_host=10.1.0.2,host=lab-proxy,hostname=lab-dhcp-1,sysDescr=Linux\ lab-dhcp-1\ 3.10.0-1127.el7.x86_64\ #1\ SMP\ Tue\ Mar\ 31\ 23:36:51\ UTC\ 2020\ x86_64 5minload="0.01",diskstat=17i 1623325390000000000

You are requesting 1.3.6.1.4.1.1625.2.3.1.4.1.6 with telegraf while doing 1.3.6.1.4.1.1625.2.3.1.4.1.6.0 in your walk.

unbelievable, sorry about that
apparently I’m blind ;).

thank you @Hipska

do you know if i could use regex on the index part?

for example, IF-MIB::ifInOctets.1 will pull in octets of interface index 1, and I want to pull this field for interface index 1 to 10.
is it possible somehow?
I’ve tried but failed.

thanks

For tabled data such as interfaces, you need to specify a inputs.snmp.table. See the documentation.

yes, i know.
the thing is that my cisco switches include all VLANs in their ifTable and ifXTable, which makes the huge tables and it loading my systems.
so I know that its possible to pull only specific table entries or specific SNMP field per interface .
my question is if instead of configuring a field per interface e.g.:

  [[inputs.snmp.field]]    
  oid = "IF-MIB::ifOperStatus.7"

using regex for indekading the interface index:

  [[inputs.snmp.field]]    
  oid = "IF-MIB::ifOperStatus.[1-24]"

I’d love to hear your thoughts. thanks

I would just walk/poll them all with the table. If wanted, you can drop the VLAN interfaces afterwards so you don’t send them to your DB storage.