Monitoring Linux Using SNMP
Monitoring Linux Using SNMP
Purpose
This document describes how to monitor Linux machines with Nagios XI using SNMP. SNMP
is an “agentless” method of monitoring network devices and servers, and is often preferable to
installing dedicated agents on target machines.
Target Audience
This document is intended for use by Nagios XI Administrators.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 1 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
• SNMP v2c
◦ Access is granted using a permission, community string and address
◦ This documentation will use the following values:
▪ Permission: rocommunity
▪ Community String: Str0ngC0mmunity
▪ Address: 10.25.5.12
• This address is the Nagios XI server address
• SNMP v3
▪ Access is granted with a username, permission, security level, authentication and privacy pass-
phrases
▪ More complicated but also more secure
▪ This documentation will use the following values:
• Username: nagios
• Permission: rouser
• Security Level: authPriv
• Authentication Protocol: SHA
• Authentication Pass-phrase: Str0ng@uth3ntic@ti0n
• Privacy Protocol: AES
• Privacy Pass-phrase: Str0ngPriv@cy
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 2 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
SNMP v2c
Using the values defined earlier, the following line will be added to the /etc/snmp/snmpd.conf file:
The following commands will create a backup of the original file and create a new config file with that line.
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.bak
echo 'rocommunity Str0ngC0mmunity 10.25.5.12' > /etc/snmp/snmpd.conf
Now restart the snmpd service using one of the following commands.
On RHEL / CentOS / Oracle Linux 7.x systems execute the following commands:
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 3 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
On Debian 9.x and Ubuntu 16.x / 18.x systems execute the following commands:
SNMP v3
Using the values defined earlier, the following command will create the SNMP v3 user and be added to the
/etc/snmp/snmpd.conf file AND the /var/lib/net-snmp/snmpd.conf file. The following commands
will create a backup of the original files, create a new config file with that line, add the SNMP v3 user and then
restart the service.
On RHEL / CentOS / Oracle Linux 7.x systems execute the following commands:
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.bak
systemctl stop snmpd.service
echo '' > /etc/snmp/snmpd.conf
net-snmp-create-v3-user -ro -a SHA -A Str0ng@uth3ntic@ti0n -x AES -X Str0ngPriv@cy nagios
sudo systemctl start snmpd.service
On Debian 9.x and Ubuntu 16.x / 18.x systems execute the following commands:
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 4 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
On RHEL / CentOS / Oracle Linux 7.x systems execute the following commands:
Note: On some systems you may need to add the address of your Nagios server to the allowed hosts file
/etc/hosts.allow.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 5 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
On RHEL / CentOS / Oracle Linux 7.x systems execute the following commands:
On Debian 9.x and Ubuntu 16.x / 18.x systems execute the following commands:
To do this, establish a terminal session to your Nagios XI server and execute the following commands to run a
test query. The examples here are targeting the Linux server 10.25.13.38 and they are using the values
defined above:
cd /usr/local/nagios/libexec
SNMP v2c
./check_snmp_storage.pl -H 10.25.13.37 -C Str0ngC0mmunity -m "^/$" -w 2 -c 4
SNMP v3
./check_snmp_storage.pl -H 10.25.13.37 -l nagios -x Str0ng@uth3ntic@ti0n -X
Str0ngPriv@cy -L SHA,AES -m "^/$" -w 2 -c 4
This check should return disk usage information from the remote Linux server, something like:
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 6 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 7 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
settings.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 8 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
With the Processes checks, double click a process in the Scanned Process List to add it to the Linux Process
field. Adjust the thresholds as required.
When you enter one number in each of the Warning and Critical fields, a WARNING alert will be generated
when the amount of processes is below the number specified in the Warning field. A CRITICAL alert will be
generated when the number of processes is equal to or below the number specified in the Critical field.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 9 / 10
Updated – January, 2021
The Industry Standard In Infrastructure Monitoring
Tip: When you enter two numbers (delimited by a comma), you are specifying a range that is acceptable for
the number of processes to be running. In the instance of the sshd in the example screenshot, a WARNING
alert will be generated if there are (1 or less) or (3 or more) instances of sshd running. A CRITICAL alert will
be generated if if there is (1 or less) or (4 or more) instances running.
Once you've finished selecting all the items you wish to monitor click Next and then complete the wizard by
choosing the required options in Step 3 - Step 5.
To finish up, click on Finish in the final step of the wizard. This will create the new hosts and services and
begin monitoring. Once the wizard applies the configuration, click the View status details for xxxxx link to
see the new host and services that were created.
Finishing Up
This completes the documentation on monitoring Linux using SNMP with Nagios XI.
If you have additional questions or other support related questions, please visit us at our Nagios Support
Forums:
https://support.nagios.com/forum
https://support.nagios.com/kb
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 10 / 10
Updated – January, 2021