# SNMP input returnuing string values

**URL:** <https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318>\
**Category:** Telegraf\
**Tags:** telegraf\
**Created:** [June 10, 2021, 9:13am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318 "2021-06-10T09:13:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahiyaz](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@ahiyaz](https://community.influxdata.com/u/ahiyaz)\
**Post date:** [June 10, 2021, 9:13am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/1 "2021-06-10T09:13:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [June 10, 2021, 10:03am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/2 "2021-06-10T10:03:19Z")

</div>

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](https://github.com/influxdata/telegraf/issues/6330#issuecomment-551843989) for an example.

---

<div class="post-metadata">

**Author:** ![ahiyaz](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@ahiyaz](https://community.influxdata.com/u/ahiyaz)\
**Post date:** [June 10, 2021, 11:01am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/3 "2021-06-10T11:01:53Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [June 10, 2021, 11:31am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/4 "2021-06-10T11:31:50Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![ahiyaz](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@ahiyaz](https://community.influxdata.com/u/ahiyaz)\
**Post date:** [June 10, 2021, 11:44am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/5 "2021-06-10T11:44:15Z")

</div>

thanks

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

```auto
[[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:

```auto
> 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

```

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [June 10, 2021, 12:26pm UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/6 "2021-06-10T12:26:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ahiyaz](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@ahiyaz](https://community.influxdata.com/u/ahiyaz)\
**Post date:** [June 10, 2021, 12:40pm UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/7 "2021-06-10T12:40:05Z")

</div>

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

thank you @Hipska

---

<div class="post-metadata">

**Author:** ![ahiyaz](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@ahiyaz](https://community.influxdata.com/u/ahiyaz)\
**Post date:** [June 13, 2021, 3:14pm UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/8 "2021-06-13T15:14:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [June 14, 2021, 6:55am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/9 "2021-06-14T06:55:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ahiyaz](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@ahiyaz](https://community.influxdata.com/u/ahiyaz)\
**Post date:** [June 14, 2021, 7:04am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/10 "2021-06-14T07:04:59Z")

</div>

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.:

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

```

using regex for indekading the interface index:

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

```

I’d love to hear your thoughts. thanks

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [June 14, 2021, 10:01am UTC](https://community.influxdata.com/t/snmp-input-returnuing-string-values/20318/11 "2021-06-14T10:01:37Z")

</div>

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.
