Install Nagios to Centos 6.4

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

and set

SELINUX=disabled

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:

# sestatus
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:

http://your-ip/nagios/

there will be a basic authentication, and you can login giving the following default credentials for nagios:

username: nagiosadmin
password: nagiosadmin

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:

http://www.be-root.com/downloads/nagios/vautour/vautour_style.zip

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-2.1.8.2.tar.gz
# gtar -xzpf check_mysql_health-2.1.8.2.tar.gz
# cd check_mysql_health-2.1.8.2
# ./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/

hostgroups.cfg

and a file

servicegroups.cfg

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
cfg_file=/etc/nagios/objects/webservers.cfg

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.

5 Replies to “Install Nagios to Centos 6.4”

  1. Hey thanks for this. Followed steps, can’t get this part going.

    [root@sentry check_mysql_health-2.1.8.2]# cp -p /usr/lib64/nagios/libexec/check_mysql_health /usr/lib64/nagios/plugins/.
    cp: cannot stat `/usr/lib64/nagios/libexec/check_mysql_health’: No such file or directory

    Ran this prior, fine.

    [root@sentry check_mysql_health-2.1.8.2]# ./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
    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for gawk… gawk
    checking whether make sets $(MAKE)… yes
    checking how to create a pax tar archive… gnutar
    checking build system type… x86_64-unknown-linux-gnu
    checking host system type… x86_64-unknown-linux-gnu
    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether make sets $(MAKE)… (cached) yes
    variable with_statefiles_dir is /var/tmp/check_mysql_health
    variable with_mymodules_dir is /usr/lib64/nagios/plugins
    variable with_mymodules_dyn_dir is /usr/lib64/nagios/plugins
    checking for sh… /bin/sh
    checking for perl… /usr/bin/perl
    checking for gzip… /bin/gzip
    checking for gawk… /bin/gawk
    checking for grep… /bin/grep
    checking for echo… /bin/echo
    checking for sed… /bin/sed
    checking for cat… /bin/cat
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating plugins-scripts/Makefile
    config.status: creating plugins-scripts/subst
    config.status: creating t/Makefile
    –with-perl: /usr/bin/perl
    –with-statefiles-dir: /var/tmp/check_mysql_health
    –with-nagios-user: nagios
    –with-nagios-group: nagios
    –with-mymodules-dir: /usr/lib64/nagios/plugins
    –with-mymodules-dyn-dir: /usr/lib64/nagios/plugins

    1. As it was stated from your output the check_mysql_health plugin was put in /var/tmp for a reason I can’t understand right now. So you can run this command:

      #cp -p /var/tmp/check_mysql_health /usr/lib64/nagios/plugins/.

      Be first sure that this file exist using for example an ls:
      #ls -lah /var/tmp/check_mysql_health

  2. Also the theme part is messing up as well.

    [root@sentry tmp]# wget http://www.be-root.com/downloads/nagios/vautour/vautour_style.zip
    –2014-01-09 19:41:08– http://www.be-root.com/downloads/nagios/vautour/vautour_style.zip
    Resolving http://www.be-root.com... 213.186.33.2, 2001:41d0:1:1b00:213:186:33:2
    Connecting to http://www.be-root.com|213.186.33.2|:80… connected.
    HTTP request sent, awaiting response… 403 Forbidden
    2014-01-09 19:41:08 ERROR 403: Forbidden.

    1. Unfortunately this file is prevented from being downloaded with wget or curl for the moment. You can download though to your personal computer through a browser and transfer it to the server, in which you are going to install nagios.

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove me that you are not a robot :) * Time limit is exhausted. Please reload the CAPTCHA.