Video Lecture

Description
SNMP stands for Simple Network Management Protocol.
We can configure Telegraf to read SNMP, save it into InfluxDB and view it in Grafana.
Common devices that support SNMP are routers, switches, printers, servers, workstations and other devices found on IP networks.
Not every network device supports SNMP, or has it enabled, and there is a good chance you don't have an SNMP enabled device available that you can use in this lecture.
So, I will show you how to install SNMP on an Ubuntu 20.04 server.
I will use our Grafana server.
| sudo apt install snmp snmpd snmp-mibs-downloader
|
Edit the snmpd.conf to set it's SNMP community. I set my community to mycommunity
| sudo nano /etc/snmp/snmpd.conf
|
| ...
rocommunity mycommunity default -V systemonly
#rocommunity6 mycommunity default -V systemonly
...
|
Restart
| sudo service snmpd restart
|
Do a test query
| snmpwalk -v 2c -c mycommunity 127.0.0.1 .
|
The response should show results with OID numbers like in this example output
1
2
3
4
5
6
7
8
9
10
11
12
13 | iso.3.6.1.2.1.1.1.0 = STRING: "Linux grafana 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10
iso.3.6.1.2.1.1.3.0 = Timeticks: (443) 0:00:04.43
iso.3.6.1.2.1.1.4.0 = STRING: "Me <me@example.org>"
iso.3.6.1.2.1.1.5.0 = STRING: "grafana"
iso.3.6.1.2.1.1.6.0 = STRING: "Sitting on the Dock of the Bay"
iso.3.6.1.2.1.1.7.0 = INTEGER: 72
iso.3.6.1.2.1.1.8.0 = Timeticks: (11) 0:00:00.11
iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.11.3.1.1
iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.15.2.1.1
iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.10.3.1.1
...
etc
|
Now to enable MIB descriptions instead of OIDs.
Edit the snmp.conf file
| sudo nano /etc/snmp/snmp.conf
|
comment out the line mibs as below, using a #
Save, and retry a query.
| snmpwalk -v 2c -c mycommunity 127.0.0.1 .
|
It should now show the MIBs descriptions in the results like in this example output.
1
2
3
4
5
6
7
8
9
10
11
12
13 | SNMPv2-MIB::sysDescr.0 = STRING: Linux grafana 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (3015) 0:00:30.15
SNMPv2-MIB::sysContact.0 = STRING: Me <me@example.org>
SNMPv2-MIB::sysName.0 = STRING: grafana
SNMPv2-MIB::sysLocation.0 = STRING: Sitting on the Dock of the Bay
SNMPv2-MIB::sysServices.0 = INTEGER: 72
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (11) 0:00:00.11
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
...
etc
|
Now to configure Telegraf to read SNMP
| sudo nano /etc/telegraf/telegraf.conf
|
Add this script below to the Inputs Plugins section
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 | [[inputs.snmp]]
agents = [ "127.0.0.1:161" ]
version = 2
community = "mycommunity"
[[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
|
Save and restart Telegraf
| sudo systemctl restart telegraf
|
⚠️ NOTE : By default SNMPD restricts how much information it returns. So currently we won't get any IF-MIB:: data from a SNMP query.
Go back into snmpd.conf and edit the view section to return more data.
| sudo nano /etc/snmp/snmpd.conf
|
Change lines
| ...
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1
...
|
to
| ...
view systemonly included .1.3.6.1.2.1
#view systemonly included .1.3.6.1.2.1.25.1
...
|
This will now return all data with the OID prefixes .1.3.6.1.2.1 which also includes interface information.