Telegraf not send metrics in Influxdb and Grafana!

Hello!
I need just snmp, snmp.traps monitoring unifi switches UP/DOWN status and drawing graphs on this data in grafana and send alert based it
I have 3 docker containers:

telegraf
influxdb 1.8
grafana

I have 30 switches and 7 AP and need monitoring it with SNMP v3
Please help correct the config and detail reply how to fix this issue
I am trying snmpwalk v3 test manually for unifi switches on a remote host, it works inside a docker container.

But unfortunately my configuration not working:

/etc/telegraf/telegraf.conf

[global_tags]
[agent]
interval = “10s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “10s”
flush_jitter = “0s”
precision = “”
hostname = “”
omit_hostname = false
logfile = “/var/log/telegraf/telegraf.log”
[outputs.influxdb]]
urls = [“http://192.168.10.52:8086”] #ip influxdb docker
database = “unifi”
username = “telegraf”
password = “passwd01”

[[inputs.system]]
[inputs.snmp]]
#Normal SNMPv3 AuthPriv SHA+AES
[[inputs.snmp]]
agents = [“192.168.0.5” , “192.168.0.7”]
version = 3
auth_protocol = “SHA”
auth_password = “Passwd01”
sec_level = “authPriv”
priv_protocol = “AES”
priv_password = “Passwd01”
sec_name = “snmp”
max_repetitions = 10
timeout = “5s”
retries = 3

name = “SwitchesSNMPv3”
#Core info
[[inputs.snmp.field]]
name = “uptime”
oid = “1.3.6.1.2.1.1.3.0”

[[inputs.snmp.field]]
name = “sysLocation”
oid = “RFC1213-MIB::sysLocation.0”

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

[[inputs.snmp_trap]]
*# Transport, local address, and port to listen on. *

  • #Transport must be “udp: //”. Omit local address to listen on all interfaces.*
    service_address = “udp: //: 162”
    timeout = “7s”

telegraf --input-filter snmp --test

2021-09-08T12:36:21Z I! Starting Telegraf 1.19.3
2021-09-08T12:36:21Z I! Using config file: /etc/telegraf/telegraf.conf
2021-09-08T12:36:21Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: Error parsing data: line 15: invalid TOML syntax

as per error message you have something invalid at line 15

{.....}
[outputs.influxdb]]

in this case it’s a missing square bracket [[outputs.influxdb]]

Thank, Giovanni_Luisotto I fixed, but metrics don’t input in influxdb…I not have ideas.
Maybe need add firewall exeption or docker containers must be in one subnet, I don’t know

have a look at the telegraf logs, to find what’s going on, or use the command:
telegraf --input-filter snmp --once

--test does not run outputs, therefore you won’t see errors related to them, --once runs the whole pipeline just once

Giovanni_Luisotto,

telegraf --input-filter snmp --once
2021-09-13T08:54:49Z I! Starting Telegraf 1.19.3
2021-09-13T08:54:49Z I! Using config file: /etc/telegraf/telegraf.conf

body of telegraf.conf
[global_tags]
dc = “unifi-switches”
[agent]
interval = “30s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “30s”
flush_jitter = “0s”
precision = “s”
hostname = “”
omit_hostname = false
logfile = “/var/log/telegraf/telegraf.log”
[[outputs.influxdb]]
urls = [“http://192.168.10.52:8086”]
timeout = “30s”
database = “unifi”
#username = “admin”
#password = “Passwd!!”
write_consistency = “any”
#[outputs.influxdb.tagdrop]
#influxdb_database = [“dbcpu”]

[[inputs.snmp]]
#Normal SNMPv3 AuthPriv SHA+AES
[[inputs.snmp]]
agents = [“192.168.0.4” , “192.168.0.5”]
version = 3
auth_protocol = “SHA”
auth_password = “Passwd!!”
sec_level = “authPriv”
priv_protocol = “AES”
priv_password = “Passwd!!”
sec_name = “snmp”
max_repetitions = 10
timeout = “30s”
retries = 3
interval = “60s”

[[inputs.snmp.field]]
name = “Switch8”
oid = “iso.3.6.1.2.1.1.5.0”
is_tag = true

#[[inputs.snmp_trap]]
#service_address = “udp://:162”
#timeout = “30s”
#SNMPv3
#version = “3”
#sec_name = “snmp”
#auth_protocol = “SHA”
#auth_password = “Passw!!”
#sec_level = “authPriv”
#priv_protocol = “AES”
#priv_password = “Passw!!”

it feels like there is no connection with the base which is in a separate dock container because the metrics are not written

have you had a look at your log file /var/log/telegraf/telegraf.log ?
Whatever happens will be written in there, and if you got no data in the database I expect to find some errors.

Giovanni_Luisotto,

cat /var/log/telegraf/telegraf.log
2021-09-15T08:01:05Z E! [inputs.snmp] Error in plugin: initializing table interface: initializing field ifDescr: translating: MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (IF-MIB): At line 1 in (none)
IF-MIB::ifDescr: Unknown Object Identifier: exit status 2
2021-09-15T08:01:05Z I! [agent] Hang on, flushing any cached metrics before shutdown
2021-09-15T08:01:05Z I! [agent] Stopping running outputs
2021-09-15T08:01:05Z E! [telegraf] Error running agent: input plugins recorded 1 errors

I’m installed inside docker container telegraf:
http://archive.ubuntu.com/ubuntu/pool/multiverse/s/snmp-mibs-downloader/snmp-mibs-downloader_1.2_all.deb
but the same result:

ls -l /usr/share/snmp/mibs
total 312
-rw-r–r–. 1 root root 1913 Jan 28 2021 GNOME-SMI.txt
-rw-r–r–. 1 root root 6845 Dec 8 2014 IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt
-rw-r–r–. 1 root root 4389 Dec 8 2014 IANA-LANGUAGE-MIB.txt
-rw-r–r–. 1 root root 3803 Dec 8 2014 IANA-RTPROTO-MIB.txt
-rw-r–r–. 1 root root 32837 Dec 8 2014 IANAifType-MIB.txt
-rw-r–r–. 1 root root 5931 Dec 8 2014 LM-SENSORS-MIB.txt
-rw-r–r–. 1 root root 15901 Dec 8 2014 NET-SNMP-AGENT-MIB.txt
-rw-r–r–. 1 root root 9160 Dec 8 2014 NET-SNMP-EXAMPLES-MIB.txt
-rw-r–r–. 1 root root 9326 Dec 8 2014 NET-SNMP-EXTEND-MIB.txt
-rw-r–r–. 1 root root 2036 Dec 8 2014 NET-SNMP-MIB.txt
-rw-r–r–. 1 root root 1215 Dec 8 2014 NET-SNMP-MONITOR-MIB.txt
-rw-r–r–. 1 root root 3350 Dec 8 2014 NET-SNMP-PASS-MIB.txt
-rw-r–r–. 1 root root 2504 Dec 8 2014 NET-SNMP-PERIODIC-NOTIFY-MIB.txt
-rw-r–r–. 1 root root 1226 Dec 8 2014 NET-SNMP-SYSTEM-MIB.txt
-rw-r–r–. 1 root root 4814 Dec 8 2014 NET-SNMP-TC.txt
-rw-r–r–. 1 root root 5039 Dec 8 2014 NET-SNMP-VACM-MIB.txt
-rw-r–r–. 1 root root 1174 Dec 8 2014 RFC-1215.txt
-rw-r–r–. 1 root root 43927 Dec 8 2014 SNMP-TLS-TM-MIB.txt
-rw-r–r–. 1 root root 8912 Dec 8 2014 SNMP-TSM-MIB.txt
-rw-r–r–. 1 root root 2163 Dec 8 2014 UCD-DEMO-MIB.txt
-rw-r–r–. 1 root root 4613 Dec 8 2014 UCD-DISKIO-MIB.txt
-rw-r–r–. 1 root root 3087 Dec 8 2014 UCD-DLMOD-MIB.txt
-rw-r–r–. 1 root root 6476 Dec 8 2014 UCD-IPFILTER-MIB.txt
-rw-r–r–. 1 root root 8118 Dec 8 2014 UCD-IPFWACC-MIB.txt
-rw-r–r–. 1 root root 18274 Dec 8 2014 UCD-SNMP-MIB-OLD.txt
-rw-r–r–. 1 root root 49561 Dec 8 2014 UCD-SNMP-MIB.txt
lrwxrwxrwx. 1 root root 23 May 29 2018 iana → /var/lib/snmp/mibs/iana
lrwxrwxrwx. 1 root root 23 May 29 2018 ietf → /var/lib/snmp/mibs/ietf
-rw-r–r–. 1 root root 965 Apr 11 2015 miblist.txt

there Host Resource MIB does not work in Telegraf container - telegraf answer
mounting /usr/share/snmp/mibs from my host
It’s means from IP switch? Thanks

I watch on unifi dream machine pro
-rw-r–r-- 1 root root 965 Apr 12 2015 miblist.txt
root@ubnt:/usr/share/snmp/mibs# cat miblist.txt
RFC1155-SMI.txt
RFC1213-MIB.txt
SMUX-MIB.txt
IPV6-TCP-MIB.txt
IPV6-UDP-MIB.txt
IPV6-MIB.txt
IPV6-TC.txt
IPV6-ICMP-MIB.txt
SNMP-COMMUNITY-MIB.txt
SNMPv2-SMI.txt
SNMPv2-TC.txt
SNMPv2-CONF.txt
AGENTX-MIB.txt
SNMP-USM-DH-OBJECTS-MIB.txt
NETWORK-SERVICES-MIB.txt
MTA-MIB.txt
HOST-RESOURCES-MIB.txt
HOST-RESOURCES-TYPES.txt
RMON-MIB.txt
HCNUM-TC.txt
IF-MIB.txt
IF-INVERTED-STACK-MIB.txt
DISMAN-EVENT-MIB.txt
DISMAN-EXPRESSION-MIB.txt
NOTIFICATION-LOG-MIB.txt
DISMAN-SCRIPT-MIB.txt
DISMAN-SCHEDULE-MIB.txt
SNMP-FRAMEWORK-MIB.txt
SNMP-MPD-MIB.txt
SNMP-NOTIFICATION-MIB.txt
SNMP-PROXY-MIB.txt
SNMP-TARGET-MIB.txt
SNMP-USER-BASED-SM-MIB.txt
SNMP-VIEW-BASED-ACM-MIB.txt
SNMPv2-TM.txt
SNMPv2-MIB.txt
TRANSPORT-ADDRESS-MIB.txt
IPV6-FLOW-LABEL-MIB.txt
EtherLike-MIB.txt
SNMP-USM-AES-MIB.txt
SCTP-MIB.txt
INET-ADDRESS-MIB.txt
TCP-MIB.txt
TUNNEL-MIB.txt
UDP-MIB.txt
BRIDGE-MIB.txt
IP-FORWARD-MIB.txt
IP-MIB.txt
DISMAN-NSLOOKUP-MIB.txt
DISMAN-PING-MIB.txt
DISMAN-TRACEROUTE-MIB.txt

Sorry but I don’t know much about the inputs.snmp and snmp, I doubt I can help you further.

Your issue is a known one looks like, as I had a look around and found some related issues:

and another post in the community:

hope it helps

@Mya - as our resident SNMP expert, are you able to help @Giovanni_Luisotto here? :slight_smile:

I agree with Giocanni_Luisotto on trying the steps laid out in this issue.