Would you like to learn how to monitor SNMP devices using Grafana on Ubuntu Linux? In this tutorial, we are going to show you how to install Grafana on Ubuntu Linux and how install InfluxDB and Telegraf to collect and store SNMP information from other devices from your network.

How does it Work?

We are going to use Telegraf agent to collect SNMP information remotely from a device.

All information collected by Telegraf will be inserted in the INfluxDB database.

Grafana will connect to the InfluxDB database, get the required information and create a dashboard.

What is Grafana?

Grafana is an open-source platform for data monitoring, analysis, and visualization that comes with a web server that allows it to be accessed from anywhere.

On the Web interface, users are able to create Grafana dashboards with panels to represent metrics over time.

Grafana Tutorial:

On this page, we offer quick access to a list of Grafana tutorials.

Tutorial – Grafana Installation on Ubuntu Linux

On the Linux console, use the following commands to install the MySQL database service.

Copy to Clipboard

Use the following command to access the MySQL command-line.

Copy to Clipboard

Use the following SQL command to create a database named grafana.

Copy to Clipboard

Use the following SQL command to create a database user named grafana.

Copy to Clipboard

Give the SQL user named grafana permission over the database named grafana.

Copy to Clipboard

On the Linux console, use the following commands to configure the Grafana APT repository.

Copy to Clipboard

Use the following command to install Grafana.

Copy to Clipboard

Edit the Grafana configuration file grafana.ini.

Copy to Clipboard

Perform the following configuration under the [Database] section.

Copy to Clipboard

Keep in mind that you need to change the MySQL username and password to reflect your environment.

Use the following command to start the Grafana service.

Copy to Clipboard

The Grafana service will start listening on TCP port 3000.

Configure the Grafana service to start automatically during boot.

Copy to Clipboard

Verify the status of the Grafana service.

Copy to Clipboard

Here is an example of the Grafana service status.

Copy to Clipboard

Open your browser and enter the IP address of your server plus :3000.

In our example, the following URL was entered in the Browser:

• http://34.216.84.149:3000

The Grafana web interface should be presented.

grafana default password

On the prompt screen, enter the Grafana Default Password login information.

• Username: admin
• Password: admin

The system will ask you to change the Grafana default password.

Grafana Default password change

After a successful login using the new password, the Grafana dashboard will be displayed.

Congratulations! You have installed Grafana on Ubuntu Linux.

Tutorial – InfluxDB Installation on Ubuntu Linux

Download and install the InfluxDB package on Ubuntu Linux.

Copy to Clipboard

Configure the InfluxDB service to start automatically during boot.

Verify the status of the influxDB service.

Copy to Clipboard

Here is an example of the influxDB service status.

Copy to Clipboard

Now, use the following command to connect to the InfluxDB command-line.

Copy to Clipboard

Congratulations! You have finished the influxDB installation on Ubuntu Linux.

Tutorial – Telegraf Installation on Ubuntu Linux

Install the required software to enable SNMP monitoring.

Copy to Clipboard

Edit the SNMP configuration file named snmp.conf.

Copy to Clipboard

Here is the original file, before our configuration.

Copy to Clipboard

Here is the new file with our configuration.

Copy to Clipboard

You have finished the SNMP client configuration.

Download and install the Telegraf package on Ubuntu Linux.

Copy to Clipboard

Configure the Telegraf service to start automatically during boot.

Verify the status of the Telegraf service.

Copy to Clipboard

Here is an example of the Telegraf service status.

Copy to Clipboard

Congratulations! You have finished the Telegraf installation on Ubuntu Linux.

Use this command if you need to edit the Telegraf configuration file:

Copy to Clipboard

Here is the default configuration file from the Telegraf service.

Copy to Clipboard

Now, let’s create a configuration file to connect the local installed Telegraf agent to a remote SNMP device.

In our example the remote snmp device will be a Linux computer running the SNMP service with the following configurations:

• Ubuntu 18.04
• Device IP address: 172.31.41.29
• Device Hostname: ip-172-31-41-29
• SNMP Comunity name: GokuBlack

Create a telegraf configuration file to enable the SNMP monitoring feature.

Copy to Clipboard

Here is the File content:

Copy to Clipboard

You need to change the IP address 172.31.41.29:161 and the SNMP community to reflect your environment.

Restart the Telegraf service.

Copy to Clipboard

Test your configuration file:

Copy to Clipboard

As a test, let’s connect to the InfluxDB installed locally.

Copy to Clipboard

Access the Telegraf database and verify what is the system monitoring.

Copy to Clipboard

As a test, select the last 2 lines of information stored on the SNMP sensor.

Copy to Clipboard

Congratulations! Your Telegraf installation is working.

Grafana Monitoring SNMP Device

Now, we need to create a connection between Grafana and the InfluxDB database.

Open your browser and enter the IP address of your Grafana server plus :3000.

In our example, the following URL was entered in the Browser:

• http://34.216.84.149:3000

The Grafana web interface should be presented.

On the Grafana dashboard, access the Configuration menu and select the Data sources option.

Grafana Datasources menu

Add the following data source: InfluxDB

Grafana data source influxdb

Perform the following data source configuration:

• URL: http://localhost:8086
• DATABASE: telegraf

Click on the Save and Test button.

grafana influxdb data source configuration

On the Grafana dashboard, access the Create menu and select the Dashboard option.

grafana create dashboard

On this screen, select the Add query option.

grafana add query

Select InfluxDB as the Query target.

Create a query to monitor your SNMP device.

Here is an image of the query that I created to monitor the network interface eth0 input.

grafana monitor network interface eth0

Here is an image of the query that I created to monitor the network interface eth0 output.

grafana monitor network interface eth0 output

Here is the Grafana query used to monitor the eth0 interface input:

Copy to Clipboard

Here is the Grafana query used to monitor the eth0 interface output:

Copy to Clipboard

Access the Visualization menu and change the Axes unit to: bits/sec

grafana axes bps

Save your dashboard, go back to the Dashboards home menu.

Select the Dashboard name that you created.

grafana snmp basic dashboard

Congratulations! You are now able to use Grafana to monitor snmp devices.