How To Install Nagios On CentOS 6

Step 1 - Install Packages on Monitoring Server
rpm -Uvh rpm -Uvh yum -y install nagios nagios-plugins-all nagios-plugins-nrpe nrpe php httpd chkconfig httpd on && chkconfig nagios on service httpd start && service nagios start

We should also enable SWAP memory on this droplet, at least 2GB:
dd if=/dev/zero of=/swap bs=1024 count=2097152 mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap echo /swap swap swap defaults 0 0 >> /etc/fstab echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p

Step 2 - Set Password Protection
Set Nagios Admin Panel Password:
htpasswd -c /etc/nagios/passwd nagiosadmin

Make sure to keep this username as "nagiosadmin" - otherwise you would have to change /etc/nagios/cgi.cfg and redefine authorized admin. Now you can navigate over to your droplet's IP address http://IP/nagios and login. You will be prompted for password you set in Step 2:

This is what the Nagios admin panel looks like: .

Install NRPE on Clients rpm -Uvh http://dl.noarch. Now we should add our hosts that will be monitored by Nagios. memcached.211. we can monitor .Since this is a fresh installation. we will need to use NRPE. Step 4 . e-mail server. From public ( (198. any open ports such as webserver. such as MySQL.fedoraproject.211.107.99). we will use cloudmail.218) and emailocean. etc. we don't have any hosts currently being monitored. For internal services that are listening on localhost.112. For example. system services.

rpm -Uvh server_port=5666 nrpe_user=nrpe nrpe_group=nrpe allowed_hosts=198.25.251 -j ACCEPT iptables -A NRPE -s 0/0 -j DROP /etc/init.211. Edit /etc/nagios/nrpe.251 dont_blame_nrpe=1 debug=0 command_timeout=60 connection_timeout=300 include_dir=/etc/nrpe.rpm yum -y install nagios nagios-plugins-all nrpe chkconfig nrpe on This next step is where you get to specify any manual commands that Monitoring server can send via NRPE to these client hosts.d/iptables save .above configuration sets Warning at 20% free disk space remaining.117. Make sure to change allowed_hosts to your own values.20 command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/vda command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200 command[check_procs]=/usr/lib64/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ Note: In check_disk above.famillecollet. the partition being checked is /dev/vda . We should also setup firewall rules to allow connections from our Monitoring server to those clients and drop everyone else: iptables -N NRPE iptables -I INPUT -s 0/0 -p tcp --dport 5666 -j NRPE iptables -I NRPE -s 198.10.5 -c 30.make sure your droplet has the same partition by running df -h / You can also modify when to trigger warnings or critical alerts .com/enterprise/remi-release-6.117. and Critical alert at 10% free space remaining.211.d/ command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10 command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15.cfg log_facility=daemon pid_file=/var/run/nrpe/nrpe.

Add Server Configurations on Monitoring Server Back on our Monitoring Current Load check_local_load!5. with different IP address and host_name: .0 } linux-server cloudmail.60% generic-service cloudmail. emailocean. nano /etc/nagios/servers/ generic-service cloudmail.cfg Add the following lines: define host { use host_name alias address } define service { use host_name service_description check_command } define service { use host_name service_description check_command notifications_enabled } define service { use host_name service_description check_command 10.0.4. Same configuration should be added for second client.cfg touch emailocean.107.0. we will have to create config files for each of our client servers: echo "cfg_dir=/etc/nagios/servers" >> /etc/nagios/! You can add more services to be monitored as desired.6.Now you can start NRPE on all of your client hosts: service nrpe start Step 5 .tk PING check_ping!! 198.cfg cd /etc/nagios/servers touch SSH check_ssh 0 generic-service cloudmail.3.cfg Edit each client's configuration file and define which services you would like

. after you are done adding all the client configurations. Now you should be able to see all the hosts and services: .cfg Finally.211..Monitor Hosts in Nagios Navigate over to your Monitoring Server's IP address http://IP/nagios and enter password set in Step 2. you should set folder permissions correctly and restart Nagios on your Monitoring Server: chown -R emailocean. linux-server 198.This is a snippet of /etc/nagios/servers/emailocean. /etc/nagios service nagios restart Step 6 .99 You can add additional clients to be monitored as /etc/nagios/servers/AnotherHostName.cfg: define host { use host_name alias address } .

And you are all done! .

Sign up to vote on this title
UsefulNot useful