In this step by step guide, we will install nagios. Nagios is a great (if not the greatest) opensource monitoring tool. You can use to monitor your hole datacenter, or lot’s of datacenters, services and networks.
1. Install the epel repository
Supposing you have not allready installed epel repository, run the following command:
# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
2. Disable selinux, iptables
In order to disable selinux edit /etc/selinux/config
# vi /etc/selinux/config
I do not recommend to disable iptables, but setting correctly it depends on your servers configuration
I disabled iptables here just to ensure that everything works and then I will apply my firewall policy.
To disable iptables you have to run the following command:
# service iptables stop
# chkconfig iptables off
To confirm that the service is not running, run the following command:
# service iptables status
and the output should be like this:
iptables: Firewall is not running.
Then run the following command to ensure that is turned off, on boot
# chkconfig --list iptables
and the output should be this:
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
reboot your system to take effect selinux configuration.
To confirm that your system has disabled selinux run:
SELinux status: disabled
Be carefull if you didn’t run
# chkconfig iptables off
then after the system reboots, the iptables service will be up.
3. Nagios Installation
Now you can install nagios using yum
# yum install nagios
When the installation completes it’s procedure, you should run:
# service httpd restart
# service nagios restart
and then visit:
there will be a basic authentication, and you can login giving the following default credentials for nagios:
You can also change these credentials to whatever you want:
# htpasswd /etc/nagios/htpasswd nagiosadmin
and here enter the password you want.
4. Change the theme of nagios
You can stay with the nagios default theme, but you can also change it to one of your choice. I like this theme:
and here I will describe how to install it.
# cd /tmp
# wget http://www.be-root.com/downloads/nagios/vautour/vautour_style.zip
# mkdir vautour
# mv vautour_style.zip vautour
# cd vautour
# unzip vautour_style.zip
# mv vautour/ /usr/share/nagios/.
# cd /usr/share/nagios/
# mv html html-backup
# mv vautour/ html
# chmod 775 html
if you miss unzip package install it via yum.
# yum install unzip
5. Install check_mysql_health
I found this plugin very helpfull to monitor my MySQL server.
to install it follow these instructions:
# cd /tmp
# wget http://labs.consol.de/download/shinken-nagios-plugins/check_mysql_health-18.104.22.168.tar.gz
# gtar -xzpf check_mysql_health-22.214.171.124.tar.gz
# cd check_mysql_health-126.96.36.199
# ./configure -prefix=/usr/lib64/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl --with-mymodules-dir=/usr/lib64/nagios/plugins --with-mymodules-dyn-dir=/usr/lib64/nagios/plugins
# cp -p /usr/lib64/nagios/libexec/check_mysql_health /usr/lib64/nagios/plugins/.
6. Configure nagios
In order to organize better your configuration files, I recommend that you should separate each configuration file for each purpose.
I add a file in /etc/nagios/conf.d/
and a file
where I include the declaration of the hostgroups and servicegroups respectively.
Then I create files for each servicegroup in /etc/nagios/objects/ for example I have a hostgroup of webservers, then I create a file webservers.cfg in this directory where I declare hosts and services. Then I add this file path to /etc/nagios/nagios.cfg as here:
# Definitions for monitoring the webservers
7. Validate Configuration
Before restarting the nagios service, you should check the configuration spelling. This can be done, by run:
nagios -v /etc/nagios/nagios.cfg
I ‘ll try to update this post, and describe how to use check_mysql_health and other tools of nagios.