Beruflich Dokumente
Kultur Dokumente
Nagios Prerequisites
Before installing Nagios, make sure you have the following installed: Apache, PHP, GCC compiler and GD development libraries.
#make all 7. Install the binaries, init script, sample configuration files, and configure permissions before starting Nagios: #make install #make install-init #make install-config #make install-commandmode 8. Edit the configuration file that will dictate which email address will receive alerts. Enter your email address. #nano /usr/local/nagios/etc/objects/contacts.cfg 9. Configure web interface. #make install-webconf 10. Create the user account nagiosadmin for logging into the web interface for Nagios. #htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 11. Restart the web server (httpd) (apache) web service running on the virtual server: #service httpd restart or #service apache2 restart 12. Compile and install the Nagios plug-ins. Make sure you are in the directory where you downloaded the source code. Note: Check the latest version in Nagios main site. #tar xvzf nagios-plugins-1.4.11.tar.gz #cd nagios-plugins-1.4.11 13. Compile and install plug-ins. #./configure --with-nagios-user=nagios --with-nagios-group=nagios #make #make install 14. Verify if Nagios is installed correctly and will start without error: #/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 15. If no errors are reported, start Nagios: #service nagios start 16. Test Nagios by logging into the web interface. From a remote machine, using the browser, enter http://<ip_address_of_server>/nagios Enter screenshot of Nagios here:
# make install-daemon # make install-daemon-config # make install-xinetd 8. Configure NRPE by editing the /etc/xinetd.d/nrpe file to allow our remote server to communicate with the monitoring server #nano vi /etc/xinetd.d/nrpe only_from = 127.0.0.1 <insert_monitoring_server_ip> <insert_remote_server_ip>
9. Add an entry in the /etc/services file for port TCP port 5666 for NRPE to communicate. #nano /etc/services Add the following entry. nrpe 5666/tcp # NRPE 10. Restart NRPE. # service xinetd restart 11. Test if NRPE is running and listening. Run the following. # netstat -at | grep nrpe This must output: tcp 0 0 *:nrpe *:*
LISTEN
12. Test if the NRPE daemon is accepting connections. Run the following command: # /usr/local/nagios/libexec/check_nrpe -H localhost This must output: NRPE v2.12 On the Monitoring Server: 14. Cd to the downloads directory. Download and extract NRPE. Download NRPE from http:// www.nagios.org/download/. Note: Check the latest version in Nagios main site. # tar -xzf nrpe-2.12.tar.gz # cd nrpe-2.12 15. Compile and configure NRPE: # ./configure # make all # make install-plugin 16. Make sure that the NRPE plugin running on the monitoring server that performs the monitoring can communicate with the remote host that we want to monitor: # /usr/local/nagios/libexec/check_nrpe -H <insert_ip_of_remote_server> This must output: NRPE v2.12
17. Configure Nagios to use the NRPE plug in by adding in the entry below. # nano /usr/local/nagios/etc/objects/commands.cfg ######################################################### NRPE CHECK COMMAND # Command to use NRPE to check remote host systems ######################################################## define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } 18. Configure Nagios, using the NRPE plugin, to communicate with the remote host. Create a template called linux-box-remote.cfg. Note: You can change the name of the template. # nano /usr/local/nagios/etc/objects/linux-box-remote.cfg define host{ name use check_period check_interval retry_interval max_check_attempts check_command notification_period notification_options contact_groups register } define host{ use host_name alias address } define service{ use host_name service_description
check_command check_nrpe!check_load } define service{ use generic-service host_name <any_name> service_description Current Users check_command check_nrpe!check_users } define service{ use generic-service host_name <any_name> service_description /dev/<paritition_name> Free Space check_command check_nrpe!check_<partition_name> } define service{ use generic-service host_name <any_name> service_description Total Processes check_command check_nrpe!check_total_procs } define service{ use generic-service host_name <any_name> service_description Zombie Processes check_command check_nrpe!check_zombie_procs } 19. Activate the new template. #nano /usr/local/nagios/etc/nagios.cfg Add the following entry. # Definitions for monitoring remote machines cfg_file=/usr/local/nagios/etc/objects/linux-box-remote.cfg 20. Restart Nagios. # service nagios restart 22. Verify if you can view the statistics of both servers (monitoring server and remote server). Log-in to the web interface of a remote machine. On the browser enter http:// <ip_address_of_server>/nagios <Enter Screenshot here>:
If you want to monitor other services running on the remote servers, you can do the following: 1. On the Remote Server that is being monitored, add the proper check command for the service. Note: You can refer the official Nagios documentation for this. #nano /usr/local/nagios/etc/nrpe.cfg Example: command[check_smbd]=/usr/local/nagios/libexec/check_procs -c 1:30 -C smbd 2. On the Monitoring Server, edit the template. In this example, that template is named linuxbox-remote.cfg. Add a service definition for each service that you added in the remote server's nrpe.cfg file. Note: You can refer the official Nagios documentation for this. #nano /usr/local/nagios/etc/objects/linux-box-remote.cfg Example service definition: define service{ use generic-service host_name <name_of_host> service_description CHECK_SMBD check_command check_nrpe!check_smbd } 3. Restart Nagios. #service nagios restart Reference: http://lancrossdata.com/index.php?option=com_content&view=article&id=91:monitoring-linuxwith-nagios&catid=52:monitoring-linux-&Itemid=69