[Guide] Monitoring Network Devices with SNMP


2 posts in this topic Last Reply

Recommended Posts

[First time writing a guide, be nice!]

 

I’m going to assume you already have Grafana, InfluxDB and Telegraf installed and running as Docker containers on your Unraid server. If not, I followed PanzerschreckGER‘s guide to get myself setup.

 

Installing SNMP

SNMP is a plugin originally developed by coppit, back in 2015. His original work is no longer maintained, and not compatible with the version of Unraid that I am using (6.8.3). In 2019, kubed_zero created a forked version which is compatible with Unraid 6.7.0. I’ll be using this.

On Unraid, go to the Community Applications tab, and search for SNMP. Install the plugin.

image.thumb.png.ddf9b14532249973e2faeac99235bf9c.png

 

Once installed, you can now try the following command in the Unraid terminal. You’ll obviously need to do this to a device that supports the SNMP protocol.

snmpwalk -v <snmp version> -c <community> <ip address>

My command was the following:

snmpwalk -v 2c -c public 192.168.0.5

If you see a lot of data fly past, everything is setup correctly and ready to go.

 

I’m using a MikroTik CRS305-1G-4S+ Switch, which uses IF-MIB, SNMPv2-MIB, BRIDGE-MIB and MIKROTIK-MIB.

If you are familiar with programming jargon, a MIB is effectively an object which stores multiple properties.

Using the snmpwalk command, I can see I have access to the IF-MIB and SNMPv2-MIB objects. Therefore I can pull any information from them. I imagine the BRIDGE-MIB and MIKROTIK-MIB databases would have to be installed seperately.

 

Definitions of what properties are available in IF-MIB and SNMPv2-MIB can be found found here and here.

 

Enabling SNMP in Telegraf

Navigate to the /appdata/telegraf directory and open up the telegraf.conf file. Uncomment the [[inputs.snmp]] section.

Add agents as necessary. I added my network switch which I used to test the snmpwalk command.

agents = ["udp://192.168.0.5:161"]

Uncomment timeout, version, community, retries and max_repetitions. I left these at the default values.

 

I used the Telegraf Documentation as a guide to setting up my configuration file.

 

Here is a copy of my [[inputs.snmp]] configuration section.

# Retrieves SNMP values from remote agents
[[inputs.snmp]]
  ## Agent addresses to retrieve values from.
  ##   example: agents = ["udp://127.0.0.1:161"]
  ##            agents = ["tcp://127.0.0.1:161"]
  agents = ["udp://192.168.0.5:161"]
 
  # Timeout for each request.
  timeout = "5s"
  # SNMP version; can be 1, 2, or 3.
  version = 2
  # SNMP community string.
  community = "public"
  # Number of retries to attempt.
  retries = 3
  # The GETBULK max-repetitions parameter.
  max_repetitions = 10
 
  ## SNMPv3 authentication and encryption options.
  ##
  ## Security Name.
  # sec_name = "myuser"
  ## Authentication protocol; one of "MD5", "SHA", or "".
  # auth_protocol = "MD5"
  ## Authentication password.
  # auth_password = "pass"
  ## Security Level; one of "noAuthNoPriv", "authNoPriv", or "authPriv".
  # sec_level = "authNoPriv"
  ## Context Name.
  # context_name = ""
  ## Privacy protocol used for encrypted messages; one of "DES", "AES" or "".
  # priv_protocol = ""
  ## Privacy password used for encrypted messages.
  # priv_password = ""
 
  ## Add fields and tables defining the variables you wish to collect.  This
  ## example collects the system uptime and interface variables.  Reference the
  ## full plugin documentation for configuration details.
  [[inputs.snmp.field]]
    oid = "RFC1213-MIB::sysUpTime.0"
    name = "uptime"
 
  [[inputs.snmp.field]]
    oid = "RFC1213-MIB::sysName.0"
    name = "source"
    is_tag = true
 
  [[inputs.snmp.table]]
    oid = "IF-MIB::ifTable"
    name = "interface"
    inherit_tags = ["source"]
 
    [[inputs.snmp.table.field]]
      oid = "IF-MIB::ifDescr"
      name = "ifDescr"
      is_tag = true
 
  [[inputs.snmp.table]]
    oid = "IF-MIB::ifXTable"
    name = "interface"
    inherit_tags = ["source"]
 
    [[inputs.snmp.table.field]]
      oid = "IF-MIB::ifDescr"
      name = "ifDescr"
      is_tag = true

This configuration will setup two new measurements; snmp and interface.

 

You’ll notice I’m using IF-MIB::ifTable and IF-MIB::ifXTable as [[inputs.snmp.table]]. According to RFC2863:

Quote

ifTable

    This table is the ifTable from MIB-II.

ifXTable

    This table contains objects that have been added to the Interface MIB as a result of the Interface Evolution effort, or replacements for objects of the original (MIB-II) ifTable that were deprecated

I used both to collect as much information as possible.

 

Now save the telegraf.conf file & restart the Telegraf container.

 

Accessing the Data in Grafana

Now in Grafana, you can access the data as shown below in some examples.

 

Uptime

Using the snmp measurement, and filtering on source, you can obtain the uptime field.

image.png.80a7024a2fa25ee87106d59214b3f3fd.png

 

Interface Statistics

Remaining fields will be in the interface measurement. You can filter on just source, or a particular interface of it.

image.png.7a466d040146a592c80671cdd73c00a3.png

 

 

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.