# # 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
Telegraf : 1.8.1
OS: Centos 7
Activated plugins - vsphere, snmp, system
To be able to get SNMP metrics and pushed to Influx output
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
I also tried doing a snmpwalk, which works perfectly fine for the ip address.
[Include gist of relevant config, logs, etc.]
What is the output of this command?
sudo -u telegraf snmptable -Ch -Cl -c public 127.0.0.1 IF-MIB::ifTable
What is the output of this command?
sudo -u telegraf snmptable -Ch -Cl -c public 127.0.0.1 IF-MIB::ifTable
-bash-4.2$ sudo -u telegraf snmptable -Ch -Cl -c public 127.0.0.1 IF-MIB::ifTable
ifIndex ifDescr ifType ifMtu ifSpeed ifPhysAddress ifAdminStatus ifOperStatus ifLastChange ifInOctets ifInUcastPkts ifInNUcastPkts ifInDiscards ifInErrors ifInUnknownProtos ifOutOctets ifOutUcastPkts ifOutNUcastPkts ifOutDiscards ifOutErrors ifOutQLen ifSpecific
IF-MIB::ifTable: No entries
Hi there,
I have the same problem. Snmpwalk works perfectly fine:
$ snmpwalk -v 3 -l authPriv -u *** -a SHA -A *** -x AES -X *** EOS2 IF-MIB::ifXTable
IF-MIB::ifName.1 = STRING: Ethernet1
IF-MIB::ifName.2 = STRING: Ethernet2
IF-MIB::ifName.3 = STRING: Ethernet3
IF-MIB::ifName.4 = STRING: Ethernet4
IF-MIB::ifName.999001 = STRING: Management1
IF-MIB::ifName.5000000 = STRING: Loopback0
IF-MIB::ifInMulticastPkts.1 = Counter32: 0
IF-MIB::ifInMulticastPkts.2 = Counter32: 1882
IF-MIB::ifInMulticastPkts.3 = Counter32: 26
IF-MIB::ifInMulticastPkts.4 = Counter32: 952
IF-MIB::ifInMulticastPkts.999001 = Counter32: 0
IF-MIB::ifInMulticastPkts.5000000 = Counter32: 0
...
but when I tries to use Telegraf 1.9.4, it can't find the module:
$ sudo docker exec -it 4115348db5d9 telegraf --input-filter snmp --test
2019-02-16T11:13:06Z I! Starting Telegraf 1.9.4
2019-02-16T11:13:06Z I! Using config file: /etc/telegraf/telegraf.conf
2019-02-16T11:13:06Z E! [telegraf] Error running agent: initializing table interface: 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::ifXTable: Unknown Object Identifier
config:
[[inputs.snmp]]
agents = [ "EOS2:161" ]
## SNMPv3 auth parameters
sec_name = "***"
auth_protocol = "SHA" # Values: "MD5", "SHA", ""
auth_password = "***"
sec_level = "authPriv" # Values: "noAuthNoPriv", "authNoPriv", "authPriv"
#context_name = ""
priv_protocol = "AES" # Values: "DES", "AES", ""
priv_password = "***"
## measurement name
name = "system"
[[inputs.snmp.field]]
name = "hostname"
oid = "SNMPv2-MIB::sysName.0"
is_tag = true
[[inputs.snmp.table]]
name = "interface"
inherit_tags = [ "hostname" ]
oid = "IF-MIB::ifXTable"
[[inputs.snmp.table.field]]
name = "ifName"
oid = "IF-MIB::ifName"
is_tag = true
System:
$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
$ docker --version
Docker version 18.09.2, build 6247962
Actually I have find a root cause, thanks to @dustnic.
In the host OS I have the respective MIBs:
$ ls /usr/share/snmp/mibs/
AGENTX-MIB.txt IANA-RTPROTO-MIB.txt IPV6-TC.txt NOTIFICATION-LOG-MIB.txt SNMP-TARGET-MIB.txt TUNNEL-MIB.txt
BRIDGE-MIB.txt IF-INVERTED-STACK-MIB.txt IPV6-UDP-MIB.txt RFC1155-SMI.txt SNMP-USER-BASED-SM-MIB.txt UCD-DEMO-MIB.txt
DISMAN-EVENT-MIB.txt IF-MIB LM-SENSORS-MIB.txt RFC1213-MIB.txt SNMP-USM-AES-MIB.txt UCD-DISKIO-MIB.txt
DISMAN-SCHEDULE-MIB.txt IF-MIB.txt MTA-MIB.txt RFC-1215.txt SNMP-USM-DH-OBJECTS-MIB.txt UCD-DLMOD-MIB.txt
DISMAN-SCRIPT-MIB.txt INET-ADDRESS-MIB.txt NET-SNMP-AGENT-MIB.txt RMON-MIB.txt SNMPv2-CONF.txt UCD-IPFWACC-MIB.txt
EtherLike-MIB.txt IP-FORWARD-MIB.txt NET-SNMP-EXAMPLES-MIB.txt SCTP-MIB.txt SNMPv2-MIB.txt UCD-SNMP-MIB.txt
HCNUM-TC.txt IP-MIB NET-SNMP-EXTEND-MIB.txt SMUX-MIB.txt SNMPv2-SMI.txt UDP-MIB.txt
HOST-RESOURCES-MIB.txt IP-MIB.txt NET-SNMP-MIB.txt SNMP-COMMUNITY-MIB.txt SNMPv2-TC.txt
HOST-RESOURCES-TYPES.txt IPV6-FLOW-LABEL-MIB.txt NET-SNMP-PASS-MIB.txt SNMP-FRAMEWORK-MIB.txt SNMPv2-TM.txt
IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt IPV6-ICMP-MIB.txt NET-SNMP-TC.txt SNMP-MPD-MIB.txt SNMP-VIEW-BASED-ACM-MIB.txt
IANAifType-MIB.txt IPV6-MIB.txt NET-SNMP-VACM-MIB.txt SNMP-NOTIFICATION-MIB.txt TCP-MIB.txt
IANA-LANGUAGE-MIB.txt IPV6-TCP-MIB.txt NETWORK-SERVICES-MIB.txt SNMP-PROXY-MIB.txt TRANSPORT-ADDRESS-MIB.txt
But the proper one is missing within the container with telegraf:
$ sudo docker exec -it 3a13205d1fd7 ls /usr/share/snmp/mibs/
GNOME-SMI.txt NET-SNMP-TC.txt
IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt NET-SNMP-VACM-MIB.txt
IANA-LANGUAGE-MIB.txt RFC-1215.txt
IANA-RTPROTO-MIB.txt SNMP-TLS-TM-MIB.txt
IANAifType-MIB.txt SNMP-TSM-MIB.txt
LM-SENSORS-MIB.txt UCD-DEMO-MIB.txt
NET-SNMP-AGENT-MIB.txt UCD-DISKIO-MIB.txt
NET-SNMP-EXAMPLES-MIB.txt UCD-DLMOD-MIB.txt
NET-SNMP-EXTEND-MIB.txt UCD-IPFILTER-MIB.txt
NET-SNMP-MIB.txt UCD-IPFWACC-MIB.txt
NET-SNMP-MONITOR-MIB.txt UCD-SNMP-MIB-OLD.txt
NET-SNMP-PASS-MIB.txt UCD-SNMP-MIB.txt
NET-SNMP-PERIODIC-NOTIFY-MIB.txt miblist.txt
NET-SNMP-SYSTEM-MIB.txt
Are there any ideas how to fix that?
Ok, so there is a workaround:
$ sudo docker cp /usr/share/snmp/mibs/. 3fa222f9cab8:/usr/share/snmp/mibs/
Basically I just copy all the MIBs from local host to container (probably, this is vey dirty solution), but afterwards I get snmpwalk from container running:
$ sudo docker exec -it 3fa222f9cab8 snmpwalk -v 3 -u Collector -l authPriv -a SHA -A SUPER_AUTH -x AES -X SUPER_PASS EOS2 IF-MIB::ifXTable
IF-MIB::ifName.1 = STRING: Ethernet1
IF-MIB::ifName.2 = STRING: Ethernet2
IF-MIB::ifName.3 = STRING: Ethernet3
IF-MIB::ifName.4 = STRING: Ethernet4
Unfortunatelly, the workournd turned to be not working, as despite the fact the SNMPWALK from container is working now, the telegraf itself continue to show errors in logs:
$ sudo docker logs 3fa222f9cab8 -f
2019-02-19T06:39:33Z E! [inputs.snmp]: Error in plugin: initializing table interface: 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::ifXTable: Unknown Object Identifier
2019-02-19T06:39:43Z E! [inputs.snmp]: Error in plugin: initializing table interface: 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::ifXTable: Unknown Object Identifier
I'm not sure what the cause is, my only guess is that it is permission related. Can you show steps starting from the official telegraf container that allow the error to be reproduced?
Hi @danielnelson, sure, see below, please:
0) test snmpwalk from Linux host:
$ snmpwalk -v 3 -u Collector -l authPriv -a SHA -A SUPER_AUTH -x AES -X SUPER_PASS EOS2 IF-MIB::ifXTable
IF-MIB::ifName.1 = STRING: Ethernet1
IF-MIB::ifName.2 = STRING: Ethernet2
IF-MIB::ifName.3 = STRING: Ethernet3
IF-MIB::ifName.4 = STRING: Ethernet4
IF-MIB::ifName.999001 = STRING: Management1
...
1) launch container:
$ sudo docker run -d -p 8125:8125 -p 8092:8092 -p 8094:8094 \
-v $PWD/data:/var/lib/snmp \
-v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro \
--add-host="EOS2:192.168.141.72" \
telegraf -config /etc/telegraf/telegraf.conf
2) look for conainer id:
$ sudo docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
86c3a0c60a7c telegraf "/entrypoint.sh -con…" 2 minutes ago Up 2 minutes 0.0.0.0:8092->8092/tcp, 8092/udp, 0.0.0.0:8094->8094/tcp, 8125/udp, 0.0.0.0:8125->8125/tcp adoring_montalcini
3) check logs within Telegraf container (reports problem):
$ sudo docker logs 86c3a0c60a7c
2019-02-21T08:04:20Z E! [inputs.snmp]: Error in plugin: initializing table interface: translating: exit status 2: /usr/share/snmp/mibs/IF-MIB.txt: No such file or directory
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::ifXTable: Unknown Object Identifier
4) check MIBs within container and find that IF-MIB is missing:
$ sudo docker exec -it 86c3a0c60a7c ls /usr/share/snmp/mibs/
GNOME-SMI.txt NET-SNMP-TC.txt
IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt NET-SNMP-VACM-MIB.txt
IANA-LANGUAGE-MIB.txt RFC-1215.txt
IANA-RTPROTO-MIB.txt SNMP-TLS-TM-MIB.txt
IANAifType-MIB.txt SNMP-TSM-MIB.txt
LM-SENSORS-MIB.txt UCD-DEMO-MIB.txt
NET-SNMP-AGENT-MIB.txt UCD-DISKIO-MIB.txt
NET-SNMP-EXAMPLES-MIB.txt UCD-DLMOD-MIB.txt
NET-SNMP-EXTEND-MIB.txt UCD-IPFILTER-MIB.txt
NET-SNMP-MIB.txt UCD-IPFWACC-MIB.txt
NET-SNMP-MONITOR-MIB.txt UCD-SNMP-MIB-OLD.txt
NET-SNMP-PASS-MIB.txt UCD-SNMP-MIB.txt
NET-SNMP-PERIODIC-NOTIFY-MIB.txt miblist.txt
NET-SNMP-SYSTEM-MIB.txt
5) upload all MIBs from local host to container:
$ sudo docker cp /usr/share/snmp/mibs/. 86c3a0c60a7c:/usr/share/snmp/mibs/
6) check that MIBs are really uploaded:
$ sudo docker exec -it 86c3a0c60a7c ls /usr/share/snmp/mibs/
AGENTX-MIB.txt NET-SNMP-VACM-MIB.txt
BRIDGE-MIB.txt NETWORK-SERVICES-MIB.txt
DISMAN-EVENT-MIB.txt NOTIFICATION-LOG-MIB.txt
DISMAN-SCHEDULE-MIB.txt RFC-1215.txt
DISMAN-SCRIPT-MIB.txt RFC1155-SMI.txt
EtherLike-MIB.txt RFC1213-MIB.txt
GNOME-SMI.txt RMON-MIB.txt
HCNUM-TC.txt SCTP-MIB.txt
HOST-RESOURCES-MIB.txt SMUX-MIB.txt
HOST-RESOURCES-TYPES.txt SNMP-COMMUNITY-MIB.txt
IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt SNMP-FRAMEWORK-MIB.txt
IANA-LANGUAGE-MIB.txt SNMP-MPD-MIB.txt
IANA-RTPROTO-MIB.txt SNMP-NOTIFICATION-MIB.txt
IANAifType-MIB.txt SNMP-PROXY-MIB.txt
IF-INVERTED-STACK-MIB.txt SNMP-TARGET-MIB.txt
IF-MIB SNMP-TLS-TM-MIB.txt
IF-MIB.txt SNMP-TSM-MIB.txt
INET-ADDRESS-MIB.txt SNMP-USER-BASED-SM-MIB.txt
IP-FORWARD-MIB.txt SNMP-USM-AES-MIB.txt
IP-MIB SNMP-USM-DH-OBJECTS-MIB.txt
IP-MIB.txt SNMP-VIEW-BASED-ACM-MIB.txt
IPV6-FLOW-LABEL-MIB.txt SNMPv2-CONF.txt
IPV6-ICMP-MIB.txt SNMPv2-MIB.txt
IPV6-MIB.txt SNMPv2-SMI.txt
IPV6-TC.txt SNMPv2-TC.txt
IPV6-TCP-MIB.txt SNMPv2-TM.txt
IPV6-UDP-MIB.txt TCP-MIB.txt
LM-SENSORS-MIB.txt TRANSPORT-ADDRESS-MIB.txt
MTA-MIB.txt TUNNEL-MIB.txt
NET-SNMP-AGENT-MIB.txt UCD-DEMO-MIB.txt
NET-SNMP-EXAMPLES-MIB.txt UCD-DISKIO-MIB.txt
NET-SNMP-EXTEND-MIB.txt UCD-DLMOD-MIB.txt
NET-SNMP-MIB.txt UCD-IPFILTER-MIB.txt
NET-SNMP-MONITOR-MIB.txt UCD-IPFWACC-MIB.txt
NET-SNMP-PASS-MIB.txt UCD-SNMP-MIB-OLD.txt
NET-SNMP-PERIODIC-NOTIFY-MIB.txt UCD-SNMP-MIB.txt
NET-SNMP-SYSTEM-MIB.txt UDP-MIB.txt
NET-SNMP-TC.txt miblist.txt
7) test snmwalk from container:
$ sudo docker exec -it 86c3a0c60a7c snmpwalk -v 3 -u Collector -l authPriv -a SHA -A SUPER_AUTH -x AES -X SUPER_PASS EOS2 IF-MIB::ifXTable
IF-MIB::ifName.1 = STRING: Ethernet1
IF-MIB::ifName.2 = STRING: Ethernet2
IF-MIB::ifName.3 = STRING: Ethernet3
IF-MIB::ifName.4 = STRING: Ethernet4
...
8) check logs for Telegraf container again:
$ sudo docker logs 86c3a0c60a7c
2019-02-21T08:11:10Z E! [inputs.snmp]: Error in plugin: initializing table interface: translating: exit status 2: /usr/share/snmp/mibs/IF-MIB.txt: No such file or directory
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::ifXTable: Unknown Object Identifier
Any ideas?
Thanks and BR,
Anton
Presumably you are restarting Telegraf after copying the MIBS over and Telegraf is running as root in the container?
nope, I don't restart telegraf. Despite adding persistent storage the MIBs aren't saved after the restart, hence I would need to copy them back again.
Interesting, I have somewhat the same problem. I get this error: _Cannot find module (HOST-RESOURCES-MIB): At line 0 in (none)_
In the /usr/share/snmp/mibs/ dir I don't have a HOST-RESOURCES-MIB.txt but I'm not so much into SNMP to judge if this is the cause.
Anyone who can confirm this file should be available to be able to read the HOST-RESOURCES-MIB SNMP data?
Basically you should have in /usr/share/snmp/mibs/ all the files you are trying to poll.
Finally solved by restarting the container:
sudo docker restart 86c3a0c60a7c
After the restart, the telegraf container starts polling the counters properly
Closing, since this doesn't appear to be a Telegraf issue.
Is it possible to restart Telegraf in the container without killing PID1? Some binaries like nginx support doing this so I thought I would ask.
I'm running the container on Kubernetes, so the MIBs are copied in when the pod (container) is deployed as persistent volumes are not handled the same way in Kubernetes....
You can reload Telegraf by sending it a SIGHUP, it will reread the configuration and restart the plugins without exiting.
I had to install this:
apt install snmp snmp-mibs-downloader
After setting the router's IP, all errors went away and everything started working. Don't forget to entire the router IP in the Dashboard
The 1.14.5-alpine now works fine the 1.14.5 does not work and still suffers from this problem