Install and configure Nagios 4 on CentOS 7

This guide helps you to install and configure of Nagios 4 on CentOS 7.Nagios is one of the widely used monitoring system that enables you to identify and helps to resolve server and network problems before it affects your critical applications. With the help of additional nagios plugins and nrpe we can monitor remote servers.

Installation of Nagios Monitoring server using source code.

I have CentOS Linux release 7.1.1503 (Core) machine for installing nagios server and following are the prerequisites

  1. Root user access for compiling and installing source codes
  2. Apache server to host nagios web interface
  3. GCC compiler
  4. OpenSSL and its development libraries
  5. GD libraries
  6. wget for downloading packages
  7. PHP support for nagios web interface
  8. Perl and its development packages
  9. unzip

Installing prerequisites

yum install gcc httpd php openssl wget openssl-devel 

Sample console output: Below are the additional dependencies packages installed

Installed:
  gcc.x86_64 0:4.8.3-9.el7          httpd.x86_64 0:2.4.6-31.el7.centos.1          openssl-devel.x86_64 1:1.0.1e-42.el7.9          php.x86_64 0:5.4.16-36.el7_1          wget.x86_64 0:1.14-10.el7_0.1         

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                   apr-util.x86_64 0:1.5.2-6.el7               cpp.x86_64 0:4.8.3-9.el7                 glibc-devel.x86_64 0:2.17-78.el7    glibc-headers.x86_64 0:2.17-78.el7    
  httpd-tools.x86_64 0:2.4.6-31.el7.centos.1 kernel-headers.x86_64 0:3.10.0-229.11.1.el7 keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.12.2-14.el7   libcom_err-devel.x86_64 0:1.42.9-7.el7
  libmpc.x86_64 0:1.0.1-3.el7                libselinux-devel.x86_64 0:2.2.2-6.el7       libsepol-devel.x86_64 0:2.1.9-3.el7      libverto-devel.x86_64 0:0.2.5-4.el7 libzip.x86_64 0:0.10.1-8.el7          
  mailcap.noarch 0:2.1.41-2.el7              mpfr.x86_64 0:3.1.1-4.el7                   pcre-devel.x86_64 0:8.32-14.el7          php-cli.x86_64 0:5.4.16-36.el7_1    php-common.x86_64 0:5.4.16-36.el7_1   
  zlib-devel.x86_64 0:1.2.7-13.el7          

Updated:
  openssl.x86_64 1:1.0.1e-42.el7.9                                                                                                                                                                            

Dependency Updated:
  openssl-libs.x86_64 1:1.0.1e-42.el7.9                    

Install perl packages

yum install perl perl-devel unzip

Now create user and group

First become the root user

su -l

Create a user for nagios and give it a password. Assign a strong password

# /usr/sbin/useradd -m nagios
# passwd nagios

Hint : simple strong password generator

# openssl rand 10 -base64

Create a group called nagcmd and add nagios, apache users to it. This is required for executing commands through nagios web interface.

# /usr/sbin/groupadd nagcmd
# /usr/sbin/usermod -a -G nagcmd nagios
# /usr/sbin/usermod -a -G nagcmd apache

Create a directory for storing the downloads

# mkdir ~/downloads;cd ~/downloads

Download latest stable release of Nagios Core source code and extract it. You can download it from https://www.nagios.org/downloads/nagios-core/

# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz

# tar -xzvf nagios-4.1.1.tar.gz

# cd nagios*

Now compile and install nagios core

# ./configure --with-nagios-group=nagcmd

Sample compilation output

*** Configuration summary for nagios 4.1.1 08-19-2015 ***:

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagcmd
       Command user/group:  nagios,nagcmd
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  ${prefix}/var/nagios.lock
   Check result directory:  ${prefix}/var/spool/checkresults
           Init directory:  /etc/rc.d/init.d
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu
          IOBroker Method:  epoll

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

Now make all

# make all

If the main program and CGIs compiled without any errors, you can continue with installing Nagios as follows

Install the main program, CGIs, and HTML files

make install

Install the init script in /etc/rc.d/init.d

make install-init

Install sample config files in /usr/local/nagios/etc

make install-config

Install and configure permissions on the directory for holding the external command file

make install-commandmode

Nagios has been installed successfully and now need to configure. So don’t start nagios at this point

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add a Comment

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