How to install Nagios 4.4.5 on Centos7?

Nagios is an Open-source monitoring tool. With Nagios, you can monitor your servers and networks whether it is lied in the datacenter or in small business organization.

It provides the feature to manage the remote server and its service on a single Dashboard. If your server found any issue, it will provide the warning on Dashboard which will allow you to track the issue before it can cause more issues. Hence, you can reduce downtime.

You can monitor Disk Usage, CPU Load, Current Users, Total Processes, etc. service with Nagios. In the following steps, we will install Nagios Core 4.4.5 on Centos 7.

Install Required Dependencies :

  1. Before we install Nagios, we will need to install its required dependencies. We will install Apache, PHP and some libraries like gcc, glibc, glibc-common and GD using yum.

    yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp
    

Create User and Group for Nagios :

  1. We will create user nagios with its password and its group nagapp. Use below command to add user and group.

    # useradd nagios
    # groupadd nagapp
  2. Add nagios user and apache user in the group nagapp with below command.

    # usermod -G nagapp nagios
    
    # usermod -G nagapp apache
  3. Download Nagios Core 4.4.5 with Nagios Plugin 2.2.1 using below command.

    wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
    wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
  4. Extract both the packages with tar.

    tar -xvf nagios-4.4.5.tar.gz
    
    tar -xvf nagios-plugins-2.2.1.tar.gz

Configure Nagios :

  1. To configure Nagiox, first go inside the Nagios Directory using cd command.

    cd nagios-4.4.5/
  2. Run below command to configure Nagios core 4.4.5

    ./configure --with-command-group=nagapp

If everything goes fine, it will provide the below output.

Output :

Creating sample config files in sample-config/ ...


*** Configuration summary for nagios 4.4.5 2019-08-20 ***:

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  /run/nagios.lock
   Check result directory:  /usr/local/nagios/var/spool/checkresults
           Init directory:  /lib/systemd/system
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /usr/sbin/sendmail
                  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.
  1. Run the make all and make install commands to compile and install all the bianaries. This will install required libraries on your server.

    # make all
    # make install
  2. Let us install init scripts for Nagios with below commands.

    # make install-init
    
  3. Run below command to run Nagios in command line.

    # make install-commandmode
    
  4. At Next step, Hit below command to install sample Nagios files.

    # make install-config
    
    

Customize Nagios Congfiguration :

  1. We will add the email account where you want to receive the nagiosadmin email alerts. Edit contacts.cfg file with below command.

    # vi /usr/local/nagios/etc/objects/contacts.cfg
    
  2. Run below command to install web-interface for Nagios.

    # make install-webconf
    
  3. Create password for the nagiosadmin. We will use this password while accessing web interface.

    # htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    New password:
    Re-type new password:
    Adding password for user nagiosadmin
  4. Restart the Apache service so our configuration setting takes effect.

    # systemctl start httpd.service
    

Compile and Install Nagios Plugin :

  1. We have already downloaded Nagios Plugin. Go to its directory and install it as per below commands.

    # cd /nagios-plugins-2.2.1
    # ./configure --with-nagios-user=nagios --with-nagios-group=nagios
  2. Now, we will verify the Nagios configuration files. You will see the following output if your setup is fine.

    # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    

Output :

Nagios Core 4.4.5
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-08-20
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
	Checked 8 services.
	Checked 1 hosts.
	Checked 1 host groups.
	Checked 0 service groups.
	Checked 1 contacts.
	Checked 1 contact groups.
	Checked 24 commands.
	Checked 5 time periods.
	Checked 0 host escalations.
	Checked 0 service escalations.
Checking for circular paths...
	Checked 1 hosts
	Checked 0 service dependencies
	Checked 0 host dependencies
	Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
  1. Start and enable the Nagios and apache service on boot.

    # systemctl enable nagios
    
    # systemctl enable httpd
  2. Finally Restart the Nagios service to take effect of all the settings.

    # systemctl enable nagios
    
    # systemctl start nagios.service

We are done with the Nagios installation on server. Now, we can access it using http://IPAddress/nagios

          

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to sync time using NTP in Ubuntu server?

Linux server users might have noticed that after adjusting the system clock to the correct time,...

How to change Magento site URL from phpMyAdmin?

Magento is a widely used E-commerce store management system. In this article, we will show you...

Fix cPanel Error -The Email Account Already Exists

Sometimes, you add an email account from cPanel, and you get an error message The Email Account...

How to Increase Open Files Limit in Ubuntu?

You may receive a message on Linux system like "Too many open files". This mean server has...

How to install Virtualmin/Webmin control panel in CentOS 7?

Please refer to the following steps to install Virtualmin/Webmin on Centos 7.x Let us update...