Skip to content

Install an SNMP Agent and Configure Telegraf SNMP Input

Video Lecture

Install an SNMP Agent and Configure Telegraf SNMP Input Install an SNMP Agent and Configure Telegraf SNMP Input


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 section.

So, I will show you how to install SNMP on an Ubuntu 20.04 server.

I will install it locally on the same server running InfluxDB.

sudo apt install snmp snmpd snmp-mibs-downloader

It is normally running after install.

sudo service snmpd status

Individual commands to either start, stop or restart are,

sudo service snmpd start
sudo service snmpd stop
sudo service snmpd restart

Do a test query

snmpwalk -v 2c -c public .

The response should show results with OID numbers like in this example output

iso. = STRING: "Linux grafana 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64"
iso. = OID: iso.
iso. = Timeticks: (443) 0:00:04.43
iso. = STRING: "Me <>"
iso. = STRING: "grafana"
iso. = STRING: "Sitting on the Dock of the Bay"
iso. = INTEGER: 72
iso. = Timeticks: (11) 0:00:00.11
iso. = OID: iso.
iso. = OID: iso.
iso. = OID: iso.

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 public .

It should now show the MIBs descriptions in the results like in this example output.

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 <>
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.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance

Now to configure Telegraf to read SNMP

sudo nano /etc/telegraf/telegraf.conf

Add this script below to the telegraf.conf file.

  agents = ["udp://"]

    oid = "RFC1213-MIB::sysUpTime.0"
    name = "uptime"

    oid = "RFC1213-MIB::sysName.0"
    name = "source"
    is_tag = true

    oid = "IF-MIB::ifTable"
    name = "interface"
    inherit_tags = ["source"]

      oid = "IF-MIB::ifDescr"
      name = "ifDescr"
      is_tag = true

Save the above configuration addition, restart Telegraf and check status.

sudo service telegraf restart
sudo service telegraf status

⚠️ 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   .
view   systemonly  included   .


view   systemonly  included   .
#view   systemonly  included   .

This will now return all data with the OID prefixes . which also includes interface information.

After a few moments, the snmp.table information should be queryable in InfluxDB and in Grafana through the interface measurement.

Sample Queries

Some sample queries to try against the InfluxDB data source in the Grafana explore tab.

from(bucket: "telegraf")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "interface")
  |> yield(name: "mean")
from(bucket: "telegraf")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "snmp")
  |> filter(fn: (r) => r["_field"] == "uptime")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

Grafana 10 and Ubuntu 22.04 Notes

When installing SNMPD, you may get a warning about a kernel upgrade. Follow the prompts accepting the defaults, and press Tab to highlight the OK option to continue.