How to Configure SNMP on CentOS Stream 9 and Integrate It with Nagios XI

Simple Network Management Protocol (SNMP) is an essential tool for monitoring and managing network devices, allowing administrators to efficiently collect and track critical system data. By enabling SNMP on CentOS Stream 9, IT teams can gain deeper visibility into system performance and streamline infrastructure management. This guide will walk you through the step-by-step process of installing and configuring SNMP on CentOS Stream 9 and integrating it with Nagios XI for seamless remote monitoring.
Requirements
Before starting, ensure you have:
- A CentOS Stream 9 system with sudo or root privileges
- A stable internet connection to download required packages
- An operational Nagios XI server (accessible from the CentOS machine)
- Optional: Basic familiarity with Linux command-line operations”
Step 1: Installing SNMP Packages
To begin, install the core SNMP packages on your CentOS Stream 9 system:
sudo dnf install -y net-snmp net-snmp-utils
This command installs the SNMP daemon and utilities required to interact with SNMP-enabled devices.
Verification
After installation, confirm the SNMP daemon is installed by checking its version:
snmpd -v
Step 2: Enabling and Starting SNMP Service
Next, enable and start the SNMP service to ensure it runs automatically on boot:
sudo systemctl enable snmpd
sudo systemctl start snmpd
The enable command configures the service for automatic startup, while start launches it immediately.
Step 3: Verifying SNMP Status
Verify that the SNMP service is operational:
sudo systemctl status snmpd
Look for Active: active (running) in the output to confirm the service is functioning. If it’s inactive or failed, review the logs with journalctl -u snmpd for troubleshooting.
Step 4: Configuring SNMP for Secure Access
The SNMP configuration file needs to be modified for proper security settings. Open the file:
sudo nano /etc/snmp/snmpd.conf
Find the com2sec directive (or add it if missing) and configure it as follows:
com2sec readonly 192.168.1.0/24 MySecureCommunity
- Replace MySecureCommunity with a unique, strong community string (e.g., X7kP9mNq2v). Avoid easily guessable values like public.
- The 192.168.1.0/24 subnet restricts queries to this network. Adjust it to match your environment (e.g., 10.0.0.0/24).
Save the file (Ctrl+O, Enter, Ctrl+X in nano), then restart the service:
sudo systemctl restart snmpd
Step 5: Testing SNMP on the Local Machine
Test SNMP functionality locally with:
snmpwalk -v2c -c MySecureCommunity localhost
This queries the SNMP daemon using SNMP v2c and your custom community string. A successful response will display system details (e.g., OID data like sysDescr.0). If you receive a timeout or error, ensure the service is running and the community string matches your configuration.
Step 6: Configuring Firewall Rules for Remote Access
Enable remote SNMP access by updating the firewall:
sudo firewall-cmd --permanent --add-port=161/udp
sudo firewall-cmd --reload
Port 161/UDP is the default for SNMP. Verify the rule is active:
sudo firewall-cmd --list-all
Look for 161/udp under ports in the output. If it’s missing, recheck your commands.”
Step 7: Testing SNMP Remotely
From a remote machine, test SNMP connectivity:
snmpwalk -v2c -c MySecureCommunity <server-ip>
Substitute <server-ip> with your CentOS Stream 9 server’s IP (e.g., 192.168.1.100). A successful query returns system data. If it fails, verify network reachability (ping <server-ip>), firewall settings, and the community string.”
Additional Testing
You can also use snmpget
for targeted queries:
snmpget -v2c -c MySecureCommunity <server-ip> sysName.0
This retrieves the system hostname (e.g., SNMPv2-MIB::sysName.0 = STRING: centos9-server).
Monitoring with Nagios XI
Step 1: Open the SNMP Wizard
- Log in to Nagios XI.
- Navigate to Configure > Run a Configuration Wizard.
- Select SNMP Monitoring Wizard.

Step 2: Add Your Host
- Enter your Host Name and type in the SNMP Community string you created.
- Select SNMP v2c unless using SNMP v3.

Step 3: Select SNMP Services
- Choose the SNMP services you want to monitor (e.g., CPU Load, Memory Usage, Network Interfaces).
- Click Next, then Finish with the default settings.
Troubleshooting Common SNMP Issues
Here are solutions to three frequent issues you might face during SNMP setup:
1. “Timeout: No Response” During snmpwalk
- Symptom:
snmpwalk -v2c -c MySecureCommunity localhost
or remote tests return a timeout. - Possible Causes: SNMP service isn’t running, firewall blocking port 161/UDP, or incorrect community string.
- Fixes:
- Check service status:
sudo systemctl status snmpd
(start withsudo systemctl start snmpd
if stopped). - Verify firewall:
sudo firewall-cmd --list-all
(add161/udp
withsudo firewall-cmd --permanent --add-port=161/udp
andsudo firewall-cmd --reload
if missing). - Ensure the community string matches
/etc/snmp/snmpd.conf
and the querying IP is in the allowed subnet (e.g.,192.168.1.0/24
).
- Check service status:
2. SNMP Service Fails to Start
- Symptom:
sudo systemctl status snmpd
showsActive: failed
. - Possible Cause: Syntax error in
/etc/snmp/snmpd.conf
or package corruption. - Fixes:
- Review logs:
journalctl -u snmpd
for errors (e.g., “invalid token”). - Restore the backup:
sudo cp /etc/snmp/snmpd.conf.bak /etc/snmp/snmpd.conf
, thensudo systemctl restart snmpd
. - Reinstall:
sudo dnf reinstall net-snmp net-snmp-utils
.
- Review logs:
3. Nagios XI Shows “Connection Refused” or No Data
- Symptom: Nagios XI can’t connect to the server or shows no SNMP metrics.
- Possible Causes: Network issue or mismatched SNMP settings.
- Fixes:
- Test connectivity: From Nagios XI, run
ping <server-ip>
andsnmpwalk -v2c -c MySecureCommunity <server-ip>
. - Confirm Nagios XI settings (community string, v2c, IP) match your SNMP config.
- Check Nagios logs:
Admin > System Information > View Log Files
for clues.
- Test connectivity: From Nagios XI, run
Quick Tip
- Use
journalctl -xe
ortail -f /var/log/messages
to dig deeper into any issue.
Conclusion
You have successfully installed and configured SNMP on CentOS Stream 9. This setup allows your server to be monitored remotely, enhancing network management capabilities. You also configured SNMP monitoring with Nagios XI, which provides a powerful interface for tracking system performance and network activity.
Next Steps
- Implement SNMP v3 for enhanced security.
- Set up SNMP traps in Nagios XI to receive alerts on critical events.
- Use custom SNMP queries to monitor specific system parameters.
By adding your SNMP-enabled server to Nagios XI, you can gain deeper insights into system health, set up alerts, and optimize network monitoring for better performance.
Share:
On this page
Related Articles
- Installing and Monitoring SUSE 11 with SNMP
- Installing Nagios Cross-Platform Agent (NCPA) on CentOS Stream 10 and Monitoring with Nagios XI
- How to Install and Configure NCPA on CentOS Stream 9 for Nagios XI Monitoring
- How to Install and Monitor SUSE 11 with Nagios Cross-Platform Agent (NCPA)
- Installing SNMP on CentOS 10 and Monitoring with Nagios XI