Telegraf snmp doesn't poll field values

Hello All,

I’m running Telegraf 1.14.5 with InfluxDB 1.6.4 on Ubuntu Server 20.04 LTS. The problem I’m having is for some reason telegraf is not collecting SNMP field data into InfluxDB while having no issue with SNMP table types e.g.

# telegraf --input-filter=snmp -config /etc/telegraf/telegraf.d/monitor-fgt01-2.conf --test
    2020-07-04T10:09:31Z I! Starting Telegraf 1.14.5
    
# telegraf --input-filter=snmp -config /etc/telegraf/telegraf.d/monitor-fgt01.conf --test
    2020-07-04T10:09:37Z I! Starting Telegraf 1.14.5
    > FortigateIF,agent_host=10.0.0.1,host=myfavhost1 ifConnectorPresent=1i,ifCounterDiscontinuityTime=0i,ifHCInBroadcastPkts=0i,ifHCInMulticastPkts=0i,ifHCInOctets=0i,ifHCInUcastPkts=0i,ifHCOutBroadcastPkts=0i,ifHCOutMulticastPkts=0i,ifHCOutOctets=0i,ifHCOutUcastPkts=0i,ifHighSpeed=0i,ifInBroadcastPkts=0i,ifInMulticastPkts=0i,ifLinkUpDownTrapEnable=1i,ifName="port10",ifOutBroadcastPkts=0i,ifOutMulticastPkts=0i,ifPromiscuousMode=2i 1593857379000000000

As you can see the first command returns nothing while the second one has all the values. The none-working configuration is as per below. The header part is the same for both files.

[[inputs.snmp]]
  agents = [ "10.0.0.1:161" ]
  version = 3
  community = "community"
  auth_protocol = "sha"
  auth_password = "password1"
  sec_level = "authPriv"
  priv_protocol = "AES"
  priv_password = "password1"
  sec_name = "user1"
  name = "snmp"
  # Timeout for each SNMP query.
   max_repetitions = 10
   timeout = "5s"
 # Number of retries to attempt within timeout.
   retries = 1

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

[[inputs.snmp.field]]
  name = "sysUpTime"
  oid = "FORTINET-FORTIGATE-MIB::fgSysUpTime"

[[inputs.snmp.field]]
  name = "sysVersion"
  oid = "FORTINET-FORTIGATE-MIB::fgSysVersion"

[[inputs.snmp.field]]
  name = "sysCpuUsage"
  oid = "FORTINET-FORTIGATE-MIB::fgSysCpuUsage"

[[inputs.snmp.field]]
  name = "sysMemUsage"
  oid = "FORTINET-FORTIGATE-MIB::fgSysMemUsage"

If I do some snmpwalk manually I get those values back just fine:

# snmpwalk -v3 -l 'authPriv' -a 'SHA' -A 'password1' -u 'user1' -x 'AES' -X 'password1' 10.0.0.1 RFC1213-MIB::sysName.0
SNMPv2-MIB::sysName.0 = STRING: HOMELAB-FGT01

# snmpwalk -v3 -l 'authPriv' -a 'SHA' -A 'password1' -u 'user1' -x 'AES' -X 'password1' 10.0.0.1 FORTINET-FORTIGATE-MIB::fgSysVersion
FORTINET-FORTIGATE-MIB::fgSysVersion.0 = STRING: v6.4.1,build1637,200604 (GA)

In the debug log it appears telegraf is trying its best to query those values (or at least to do snmptranslate on them).

2020-07-04T05:12:31Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "RFC1213-MIB::sysName.0"
2020-07-04T05:12:32Z D! [inputs.snmp] executing "snmptranslate" "-Td" "-Ob" "FORTINET-FORTIGATE-MIB::fgSysVersion"

Is there anything else I can do to troubleshoot the issue further, please?
Thank you.

I think you need to add .0 to the end of your fields.

You may have noticed when you walked the OID you got a child OID with .0 appended in response. When Telegraf retrieves top level fields it doesn’t do a walk it does a regular get, in the same way that the snmpget works:

snmpget 10.0.0.1 FORTINET-FORTIGATE-MIB::fgSysVersion

You Sir are a genius.
Thank you for your help, that change with the “.0” at the end has fixed the issue.