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 data center or in the 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 a user Nagios with its password and its group nagapp. Use the below command to add user and group.

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

    # usermod -G nagapp nagios
    
    # usermod -G nagapp apache
  3. Download Nagios Core 4.4.5 with Nagios Plugin 2.2.1 using the 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 binaries. This will install the 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 the below command to run Nagios in the command line.

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

    # make install-config
    
    

Customize Nagios Configuration :

  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 the server. Now, we can access it using http://IPAddress/nagios

Related Articles

How to set up a cron to take MySQL Database Backup daily and remove the older backup files that are older than 10 days?

Login to your Linux server using ssh. Open your crontab using the below command Crontab -e...

How to add IP Address on Ubuntu 18.04 using netplan?

We can configure IP Address on ubuntu 18.04 using Netplan. It is a different method to add IP...

How to configure Exim outgoing IP address from WHM?

By Default, All the outgoing emails from the Exim will be sent from the server’s primary IPv4...

How to fix su USER Fails With "su: cannot create child process: Resource temporarily unavailable" Error in CloudLinux?

You may face the below error while switching the accounts using su command. su accutest su:...

How to Disable SSH Login for the Root User in Linux?

Please refer to the following article to disable root login using SSH in Linux.  Login to your...

  • 0 Users Found This Useful

Was this answer helpful?