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 https://www.gitmemory.com/issue/influxdata/telegraf/5837/504640738 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:
opened 06:46AM - 22 Oct 18 UTC
closed 07:21PM - 19 Jun 19 UTC
area/snmp
### Relevant telegraf.conf:
```
# # Retrieves SNMP values from remote agents
… [[inputs.snmp]]
# agents = [ "127.0.0.1:161" ]
agents = ["ipdadrres_switch:161"]
# ## Timeout for each SNMP query.
timeout = "5s"
# ## Number of retries to attempt within timeout.
retries = 3
# ## SNMP version, values can be 1, 2, or 3
version = 3
#
# ## SNMP community string.
community = "public"
#
# ## The GETBULK max-repetitions parameter
max_repetitions = 10
#
# ## SNMPv3 auth parameters
sec_name = "snmpuser"
auth_protocol = "SHA" # Values: "MD5", "SHA", ""
auth_password = "somethingsecret"
sec_level = "authNoPriv" # Values: "noAuthNoPriv", "authNoPriv", "authPriv"
## #context_name = ""
priv_protocol = "AES" # Values: "DES", "AES", ""
priv_password = "somethingsecret"
[inputs.snmp.field]]
name = "hostname"
oid = "RFC1213-MIB::sysName.0"
is_tag = true
[[inputs.snmp.field]]
name = "uptime"
oid = "DISMAN-EXPRESSION-MIB::sysUpTimeInstance"
# IF-MIB::ifTable contains counters on input and output traffic as well as errors and discards.
[[inputs.snmp.table]]
name = "interface"
inherit_tags = [ "hostname" ]
oid = "IF-MIB::ifTable"
# Interface tag - used to identify interface in metrics database
[[inputs.snmp.table.field]]
name = "ifDescr"
oid = "IF-MIB::ifDescr"
is_tag = true
# IF-MIB::ifXTable contains newer High Capacity (HC) counters that do not overflow as fast for a few of the ifTable counters
[[inputs.snmp.table]]
name = "interface"
inherit_tags = [ "hostname" ]
oid = "IF-MIB::ifXTable"
# Interface tag - used to identify interface in metrics database
[[inputs.snmp.table.field]]
name = "ifDescr"
oid = "IF-MIB::ifDescr"
is_tag = true
# EtherLike-MIB::dot3StatsTable contains detailed ethernet-level information about what kind of errors have been logged on an interface (such as FCS error, frame too long, etc)
[[inputs.snmp.table]]
name = "interface"
inherit_tags = [ "hostname" ]
oid = "EtherLike-MIB::dot3StatsTable"
# Interface tag - used to identify interface in metrics database
[[inputs.snmp.table.field]]
name = "ifDescr"
oid = "IF-MIB::ifDescr"
is_tag = true
```
### System info:
Telegraf : 1.8.1
OS: Centos 7
Activated plugins - vsphere, snmp, system
### Steps to reproduce:
1. ...
2. ...
### Expected behavior:
To be able to get SNMP metrics and pushed to Influx output
### Actual behavior:
When running the telegraf test for config, fetches other metrics for System but no SNMP metrics
`$telegraf --config /etc/telegraf/telegraf.conf --test`
Also when checking the status
```
$systemctl status telegraf.service -l
: Cannot find module (IPV6-UDP-MIB):At line 0 in (none)
: Cannot find module (IPV6-FORWARD-MIB):At line 0 in (none)
: Cannot find module (NET-SNMP-PASS-MIB):At line 0 in (none)
: Cannot find module (NET-SNMP-EXTEND-MIB):At line 0 in (none)
: Cannot find module (UCD-DLMOD-MIB):At line 0 in (none)
: Cannot find module (SNMP-NOTIFICATION-MIB):At line 0 in (none)
: Cannot find module (IF-MIB):At line 0 in (none)
: IF-MIB::ifTable:Unknown Object Identifier
```
### Additional info:
I also tried doing a snmpwalk, which works perfectly fine for the ip address.
[Include gist of relevant config, logs, etc.]
opened 08:06PM - 24 Mar 18 UTC
closed 08:17PM - 14 Oct 21 UTC
telegraf
Hello,
i have installed Telegraf container v 1.5.3, but with this configuration… doesn't work:
`# Inet interface
[[inputs.snmp.table]]
oid = "IF-MIB::ifTable"
[[inputs.snmp.table.field]]
is_tag = true
oid = "IF-MIB::ifDescr"`
is resulting in this error:
`! Error in plugin [inputs.snmp]: initializing table : translating: exit status 2: 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 0 in (none)
IF-MIB::ifTable: Unknown Object Identifier`
I have tried with 1.5 and 1.4, is the same thing.
Regards
E.
and another post in the community:
I created a custom docker build see below, which solve the problels.
# Based on https://github.com/weldpua2008/docker-net-snmp
FROM telegraf
RUN export DEBIAN_FRONTEND=noninteractive && \
export DEBIAN_RELEASE=$(awk -F'[" ]' '/VERSION=/{print $3}' /etc/os-release | tr -cd '[[:alnum:]]._-' ) && \
echo "remove main from /etc/apt/sources.list" && \
sed -i '/main/d' /etc/apt/sources.list && \
echo "remove contrib from /etc/apt/sources.list" && \
se…
hope it helps
popey
September 17, 2021, 1:36pm
9
@Mya - as our resident SNMP expert, are you able to help @Giovanni_Luisotto here?
Mya
September 17, 2021, 5:18pm
10
I agree with Giocanni_Luisotto on trying the steps laid out in this issue.