Share this post

Table of Contents

How to Monitor Ubuntu 22 using SNMP

|

Picture of Louie Mattia
Louie Mattia

Simple Network Management Protocol (SNMP) is a widely used protocol designed to manage and monitor network devices such as routers, switches, servers, and printers. It allows administrators to gather information on network performance, troubleshoot issues, and configure devices remotely. By setting up SNMP on Ubuntu 22, you can enable comprehensive monitoring through Nagios XI, making it easier to track system health and performance.

Prerequisites

  • A working instance of Nagios XI
  • A internet connection

Step 1: Install SNMP Daemon onto Ubuntu 22

To start, we need to install the SNMP Daemon (snmpd) on Ubuntu. The SNMP Daemon is responsible for allowing SNMP-enabled tools, like Nagios XI, to collect and manage data from the system. First, update your package lists with the following command:

sudo apt update

This command updates the local package database to ensure we have the latest information about available software packages. After the update is complete, install snmpd by running the following command:

sudo apt install snmpd

For testing purposes, we’ll also install the snmp package. This is primarily needed for running the snmpwalk command, which helps us verify the configuration locally. To install it, enter the following command:

sudo apt install snmp

Step 2: Configure SNMP

Now that it is installed we need to configure it, as it is now we will not be able to pull any information from the device. We need to edit the snmp.conf file, to do this use the command:

sudo nano /etc/snmp/snmpd.conf

We are looking for a few sections in this, first thing we want to do is find the agentadress section.

agentaddress line
agentaddress in snmpd.conf

You can change this to match the IP address of your instance of Nagios XI for greater security, but if you use what’s listed above, it will work, it will allow the wizard we are using to recognize and access it through SNMP. Now we do want snmpwalk to access this, we need to change the view section now.

Screenshot 2025 02 11 153611
views in snmpd.conf

These SNMP view definitions specify which parts of the MIB tree are accessible to users. The first line grants access to standard system-related information (under .1.3.6.1.2.1), while the second allows access to enterprise-specific objects (under .1.3.6.1.4.1), thereby controlling the visibility of SNMP data for monitoring and management purposes. Next, the rocommunity line defines the read-only community string for SNMP access, which acts as a password for SNMP clients to retrieve data from the SNMP daemon. In this example, we will be using the default community string “public” for simplicity, though for enhanced security, it’s recommended to replace it with a more secure word or phrase of your choice.

rocommunity string in snmpd.conf
rocommunity in snmpd.conf

Step 3: Restart the service

The next step is to restart the SNMP service so that the changes take effect. To do this, simply run the following command:

sudo service snmpd restart

This will restart the SNMP service, and you shouldn’t receive any output if everything is configured correctly. If you do get output, it likely indicates an error in the snmpd.conf file—most often a typo in one of the lines. Please review the file and check for any mistakes. Once that’s sorted, we’ll want to verify that our configurations are working. To do this, we can use the snmpwalk command locally. Alternatively, if you have access to the Nagios XI Linux host, you can perform the test from there as well. The command to use is:

snmpwalk -v 2c -c <rocommunity> localhost/<ip address>

You should receive a very long output, whether you’re testing locally or through the Nagios XI Linux host. If this happens, it confirms that SNMP is set up correctly. It’s even better if you’re able to get it working through the Nagios XI Linux host, as this will verify that the system is correctly receiving and processing SNMP data for monitoring.

Step 4: Set up on Nagios XI

With everything set up, we can now configure monitoring through Nagios XI using the Linux SNMP Wizard. You’ll need to enter the IP address of your Ubuntu device along with the rocommunity string. The SNMP daemon supports multiple versions of SNMP, so the default settings for both the SNMP version and port should work perfectly.

Screenshot 2025 02 11 151739
Linux SNMP Wizard First Step

After configuring the settings, you can choose the hostname and select any services you want to monitor through SNMP. Once these steps are completed, your host will be set up for monitoring. By clicking on the hostname, you’ll see that it is being actively monitored and collecting data for the selected services.

Screenshot 2025 02 11 111531
Host Status for SNMP Host
Screenshot 2025 02 11 153207
Services of new Host

Conclusion

With these steps, we’ve successfully set up Ubuntu 22 to be monitored using SNMP with Nagios XI. If you encounter any issues, please refer to the Nagios Support Forum for assistance. Alternatively, if you prefer to monitor using the Nagios Cross-Platform Agent, you can find more information here.