Celebrate Our 22nd Anniversary with Huge Savings! Up to 70% Off

How to Install Nagios 4.4.5 on CentOS 7?

Nagios Core (formerly known as Nagios) is an open-source monitoring tool that is used to monitor servers and networks, whether it is in a data center or a small business organization.

Nagios Core provides the feature to manage the remote server and its service on a single Dashboard. If your server has any issues, Nagios Core will provide the warning on the Dashboard, allowing you to track the issue before it can cause more serious trouble. Hence, you can reduce downtime.

With Nagios Core, you can monitor Disk Usage, CPU Load, Current Users, Total Processes, etc. 

In the following steps, we will install Nagios Core 4.4.5 on CentOS 7 – 

Install Required Dependencies 

1. Before installing Nagios Core 4.4.5, we will need to install its required dependencies, including Apache, PHP, and some libraries such as 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

We will create a user Nagios with its password and its group nagapp.

1. Use the command below to add the 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 this 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 packages with tar.

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

Configure Nagios 

1. First, configure Nagios, and go inside the Nagios directory using the cd command.

cd nagios-4.4.5/

2. Run this command to configure Nagios core 4.4.5 – 

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

If everything goes fine, it will give the output as shown below – 

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.

3. 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

4. Let us install init scripts for Nagios with the commands given below – 

# make install-init

5. Execute the below-given command to run Nagios in the command line – 

# make install-commandmode

6. At the next step, run this command to install sample Nagios files – 

# make install-config


 

Customize Nagios Configuration

We will add the email account where you want to receive the nagiosadmin email alerts.

1. Edit the contacts.cfg file with this command – 

# vi /usr/local/nagios/etc/objects/contacts.cfg

2. Run this command to install the web interface for Nagios – 

# make install-webconf

3. Create a password for the nagiosadmin. We will use this password while accessing the 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 

We have already downloaded the Nagios plugin.

1. Now, go to its directory and install it as per the 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

3. Start and enable the Nagios and apache service on boot.

# systemctl enable nagios
# systemctl enable httpd

4. Finally, Restart the Nagios service to take effect all the settings.

# systemctl enable nagios
# systemctl start nagios.service  

We have completed the Nagios installation on the server.

Now, we can access it using http://IPAddress/nagios

 


Was this answer helpful?

« Back

chat