Transcription

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPPurposeThis document describes how to monitor Linux machines with Nagios XI using SNMP. SNMPis an “agentless” method of monitoring network devices and servers, and is often preferable toinstalling dedicated agents on target machines.Target AudienceThis document is intended for use by Nagios XI Administrators.Install SNMP On The Remote Linux MachineBefore you can monitor a Linux machine using SNMP, you'll need to install and configure the necessary. First,you'll need to install the net-snmp package on the Linux machine. Login to the Linux machine as the rootuser to complete the next steps.On RHEL / CentOS systems use the following command:yum install net-snmpOn Debian / Ubuntu based systems use the following command:sudo apt-get install snmpd libsnmp-dev1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 1 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPConfigure SNMP Access On The Remote Linux MachineNow you must configure access permissions for SNMP on the Linux machine. This guide will focus on SNMPv2c and SNMP v3. 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 passphrases 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: [email protected]@ti0n Privacy Protocol: AES Privacy Pass-phrase: [email protected] Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 2 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPSNMP v2cUsing the values defined earlier, the following line will be added to the /etc/snmp/snmpd.conf file:rocommunity Str0ngC0mmunity 10.25.5.12The following commands will create a backup of the original file and create a new config file with that line.On RHEL / CentOS / Oracle Linux systems execute the following commands:cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.bakecho 'rocommunity Str0ngC0mmunity 10.25.5.12' /etc/snmp/snmpd.confOn Debian / Ubuntu systems execute the following commands:sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.baksudo sh -c "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:systemctl restart snmpd.service1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 3 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPOn Debian 9.x and Ubuntu 16.x systems execute the following commands:sudo systemctl restart snmpd.serviceSNMP v3Using 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 commandswill create a backup of the original files, create a new config file with that line, add the SNMP v3 user and thenrestart the service.On RHEL / CentOS / Oracle Linux 7.x systems execute the following commands:cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.baksystemctl stop snmpd.serviceecho '' /etc/snmp/snmpd.confnet-snmp-create-v3-user -ro -a SHA -A [email protected]@ti0n -x AES -X [email protected] nagiossudo systemctl start snmpd.serviceOn Debian 9.x and Ubuntu 16.x systems execute the following commands:sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.baksudo systemctl stop snmpd.servicesudo sh -c "echo '' /etc/snmp/snmpd.conf"sudo net-snmp-create-v3-user -ro -a SHA -A [email protected]@ti0n -x AES -X [email protected] nagiossudo systemctl start snmpd.service1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 4 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPConfigure Inbound Firewall Rules On The Remote Linux MachineIf you have the operating system firewall enabled you'll need to allow UDP port 161 inbound. The commandsfor this vary depending on your operating system.On RHEL / CentOS / Oracle Linux 7.x systems execute the following commands:firewall-cmd --zone public --add-port 161/udpfirewall-cmd --zone public --add-port 161/udp --permanentOn Ubuntu systems execute the following commands:sudo ufw allow snmpsudo ufw reloadOn Debian systems execute the following commands:iptables -I INPUT -p udp --destination-port 161 -j ACCEPTapt-get install iptables-persistentAnswer yes to saving existing rules.Note: On some systems you may need to add the address of your Nagios server to the allowed hosts file/etc/hosts.allow.Configure The SNMP Daemon To Start On BootConfigure the SNMP daemon to automatically start when the Linux machine reboots.1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 5 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPOn RHEL / CentOS / Oracle Linux 7.x systems execute the following commands:systemctl enable snmpd.serviceOn Debian 9.x and Ubuntu 16.x systems execute the following commands:sudo systemctl enable snmpd.serviceTesting SNMP CommunicationBefore you continue, you'll need to make sure that the Nagios XI server can communicate with the remoteLinux server using SNMP.To do this, establish a terminal session to your Nagios XI server and execute the following commands to run atest query. The examples here are targeting the Linux server 10.25.13.38 and they are using the valuesdefined above:cd /usr/local/nagios/libexecSNMP v2c./check snmp storage.pl -H 10.25.13.37 -C Str0ngC0mmunity -m " / " -w 2 -c 4SNMP v3./check snmp storage.pl -H 10.25.13.37 -l nagios -x [email protected]@ti0n [email protected] -L SHA,AES -m " / " -w 2 -c 4This 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-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 6 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMP/: 11%used(1550MB/13892MB) ( 4%) : CRITICALImportant: If the command doesn't return data, it likely means that SNMP is not configured properly, or that afirewall issue exists on the remote server. In that case, go through the steps in the previous section to ensureeverything is configured properly.Using The Linux SNMP WizardTo begin using the Linux SNMP wizard navigate via the top menu bar to Configure Run a configuringwizard, and select the Linux SNMP wizard. In the following screenshot you can see how the search fieldallows you to quickly find a wizard.On Step 1 you will be asked to supplythe address of the server you willmonitor via SNMP.You will also have to provide theappropriate SNMP Settings.This screenshot shows SNMP v2c1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 7 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPsettings.This screenshot shows SNMP v3settings.Click Next to progress to step 2.When you proceed to Step 2, thewizard will perform an SNMP queryagainst the Linux server to get a list ofthe available disks and processes.Select the server metrics you wish tomonitor and adjust the thresholds asrequired.1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 8 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPWith the Disk Usage checks,double click a disk in the ScannedDisk List to add it to the Drive field.Adjust the thresholds as required.With the Processes checks, double click a process in the Scanned Process List to add it to the Linux Processfield. Adjust the thresholds as required.When you enter one number in each of the Warning and Critical fields, a WARNING alert will be generatedwhen the amount of processes is below the number specified in the Warning field. A CRITICAL alert will begenerated 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-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 9 / 10Updated – March, 2021

The Industry Standard In Infrastructure MonitoringNagios XIMonitoring Linux Using SNMPTip: When you enter two numbers (delimited by a comma), you are specifying a range that is acceptable forthe number of processes to be running. In the instance of the sshd in the example screenshot, a WARNINGalert will be generated if there are (1 or less) or (3 or more) instances of sshd running. A CRITICAL alert willbe 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 bychoosing 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 andbegin monitoring. Once the wizard applies the configuration, click the View status details for xxxxx link tosee the new host and services that were created.Finishing UpThis 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 SupportForums:https://support.nagios.com/forumThe Nagios Support Knowledgebase is also a great support resource:https://support.nagios.com/kb1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671INTL: 1-651-204-9102www.nagios.com 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner.Page 10 / 10Updated – March, 2021

you'll need to install the net-snmp package on the Linux machine. Login to the Linux machine as the root user to complete the next steps. On RHEL / CentOS systems use the following command: yum install net-snmp On