Share this post
Ayub Huruse
Table of Contents
Step-by-Step Guide: Setting Up SNMP on Ubuntu 24 for Nagios XI
|
Ayub Huruse
![](https://library.nagios.com/wp-content/uploads/2025/02/snmp_shutterstock_2155627375.jpg)
Efficient network monitoring is essential for maintaining system performance and preventing downtime. SNMP (Simple Network Management Protocol) provides a robust mechanism for monitoring network devices and Linux servers with Nagios XI, eliminating the need for additional agents.
This guide walks you through the installation and configuration of SNMP on Ubuntu 24 for seamless integration with Nagios XI. We will cover both SNMP v2c (widely used but less secure) and SNMP v3 (offering authentication and encryption for enhanced security).
Target Audience
This document is intended for Nagios XI administrators who want to implement SNMP-based monitoring on Ubuntu machines to gain real-time visibility into system metrics.
Prerequisites
Before proceeding, ensure the following:
- You have administrative or sudo privileges on the Ubuntu machine.
- You are using Ubuntu 24.04 or later.
- Nagios XI is installed and accessible, with the SNMP Wizard enabled.
Step 1: Install SNMP Packages
To install SNMP and the necessary libraries, log in to your Ubuntu machine and execute the following command:
sudo apt-get update
sudo apt-get install snmpd libsnmp-dev -y
This updates your package list and installs:
libsnmp-dev
(SNMP development libraries for querying SNMP devices)snmpd
(the SNMP daemon for handling SNMP requests)
Step 2: Configure SNMP
SNMP v2c Configuration
To configure SNMP v2c, first, create a backup of the existing configuration:
sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
Now, edit the SNMP configuration file:
sudo nano /etc/snmp/snmpd.conf
Find and modify the following line to define the community string and allow access from your Nagios XI server (replace Str0ngC0mmunity
with your desired community string and 10.25.5.12
with your Nagios XI server’s IP address):
rocommunity Str0ngC0mmunity 10.25.5.12
Save the file and restart the SNMP service:
sudo systemctl restart snmpd.service
SNMP v3 Configuration (Optional, More Secure)
To configure SNMP v3, create an SNMP user with authentication and encryption:
sudo net-snmp-create-v3-user -ro -a SHA -A Str0ng@uth3ntic@ti0n -x AES -X Str0ngPriv@cy nagios
-a SHA
→ Specifies SHA for authentication (useMD5
if needed, but it’s less secure)-x AES
→ Enables AES encryption (alternatively, useDES
for lower security)
Restart the SNMP service:
sudo systemctl restart snmpd.service
Step 3: Configure Firewall Rules
If your Ubuntu firewall (ufw
) is enabled, allow SNMP traffic:
sudo ufw allow snmp
sudo ufw reload
For better security, allow SNMP traffic only from the Nagios XI server:
sudo ufw allow from 10.25.5.0/24 to any port 161 proto udp
Step 4: Enable SNMP Service on Boot
To ensure SNMP starts automatically on system boot, run:
sudo systemctl enable snmpd.service
Step 5: Test SNMP Communication
On your Nagios XI server, test SNMP connectivity using the following commands.
For SNMP v2c:
snmpwalk -v2c -c Str0ngC0mmunity 10.25.5.12
For SNMP v3:
snmpwalk -v3 -u nagios -l authPriv -a SHA -A Str0ng@uth3ntic@ti0n -x AES -X Str0ngPriv@cy 10.25.5.12
Expected Output (Example)
iso.3.6.1.2.1.1.1.0 = STRING: "Linux myserver 5.15.0-72-generic"
iso.3.6.1.2.1.1.3.0 = Timeticks: (100032) 0:16:40.32
Troubleshooting Steps
If SNMP does not return data:
1. Verify SNMP Service is Running:
sudo systemctl status snmpd
2. Check Listening Ports:
sudo systemctl status snmpd
3. Ensure Firewall Allows Traffic:
sudo ufw status
4. Check SNMP Logs for Errors:
sudo journalctl -u snmpd --no-pager | tail -20
5. Test Local SNMP Response:
snmpwalk -v2c -c Str0ngC0mmunity -O e 127.0.0.1
Step 6: Add Ubuntu Host to Nagios XI Using SNMP Wizard
1. In Nagios XI, navigate to Configure > Run a configuring wizard.
2. Search for and select the Linux SNMP wizard.
3. Enter the Ubuntu machine’s IP address and SNMP credentials.
![Step-by-Step Guide: Setting Up SNMP on Ubuntu 24 for Nagios XI 1 Screenshot 2025 02 11 151739 1](https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-11-151739-1.png)
4. Click Next, select the system metrics to monitor (CPU, memory, disk, network traffic, etc.).
5. Apply the configuration and verify that Nagios XI is collecting SNMP data.
![Step-by-Step Guide: Setting Up SNMP on Ubuntu 24 for Nagios XI 2 Screenshot 2025 02 11 153207 1](https://library.nagios.com/wp-content/uploads/2025/02/Screenshot-2025-02-11-153207-1-1024x338.png)
Common Issues & Fixes
- Host appears “Down” in Nagios XI:
- Check SNMP configuration and firewall rules.
- Incorrect SNMP credentials error:
- Verify the community string (SNMP v2c) or authentication details (SNMP v3).
- No data returned in
snmpwalk
:- Ensure
snmpd
is running and listening on port 161.
- Ensure
Conclusion
You have successfully installed and configured SNMP on Ubuntu for monitoring with Nagios XI. If you encounter issues, check the firewall settings and ensure the correct SNMP configurations are applied.
For further support, visit the Nagios Support Forum or the Nagios Knowledgebase.