How to install Nagios 4.4.3 on RHEL 7 & CentOS 7

Nagios is an open source monitoring tool that helps us monitor services and applications running on Windows, Linux, routers, and other network devices.

 

With the help of Nagios, you can monitor basic services and features. We can access Nagios using the web interface that comes with bundles and configurations and this should be done at the file level.

Services List

This Tutorial describes how you can monitor private services and attributes of Linux/UNIX servers, such as:

Attributes

  • CPU load
  • Memory usage
  • Disk usage
  • Logged in users
  • Running processes
  • etc.

Private Services

  • HTTP
  • FTP
  • SSH
  • SMTP
  • etc  

Prerequisites

Before installing Nagios, the system needs to meet the requirements for installing Nagios. To install the Web Server (httpd), PHP, compilers, and development libraries.

Install all packages in a single command.

[root@fosnix ~]# yum -y install httpd php gcc glibc glibc-common wget perl gd gd-devel unzip zip

Create a Nagios user and nagcmd group for allowing the external commands to be executed through the web interface, add the Nagios and apache user to be a part of the nagcmd group.

[root@fosnix ~]# useradd nagios
[root@fosnix ~]# groupadd nagcmd
[root@fosnix ~]# usermod -a -G nagcmd nagios
[root@fosnix ~]# usermod -a -G nagcmd apache

Install Nagios Server

Download the latest version of Nagios Core using the terminal.

[root@fosnix ~]# cd /tmp/
[root@fosnix ~]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.3.tar.gz
[root@fosnix ~]# tar -zxvf nagios-4.4.3.tar.gz
[root@fosnix ~]# cd /tmp/nagios-4.4.3

Compile and Install Nagios.

[root@fosnix ~]# ./configure --with-nagios-group=nagios --with-command-group=nagcmd
[root@fosnix ~]# make all
[root@fosnix ~]# make install
[root@fosnix ~]# make install-init
[root@fosnix ~]# make install-config
[root@fosnix ~]# make install-commandmode

Install Nagios Web Interface

Install the Nagios web configuration using the following command.

[root@fosnix ~]# make install-webconf

Run the following command to install a Nagios exfoliation theme

[root@fosnix ~]# make install-exfoliation

Create a user account (nagiosadmin) for logging into the Nagios web interface. Remember the password that you assign to this user – you’ll need it later.

[root@fosnix ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache web server to make the new settings take effect.

[root@fosnix ~]# systemctl restart httpd
[root@fosnix ~]# systemctl enable httpd

Configure Nagios Server

Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You’ll need to make just one change before you proceed.

 

Edit

the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.

[root@fosnix ~]# vi /usr/local/nagios/etc/objects/contacts.cfg

Change the Email address field to receive the notification.

define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email admin@fosnix.com ; ***** CHANGE THIS TO YOUR EMAIL ADDRESS *****

Install Nagios Plugins

Download Nagios Plugins to /tmp directory.

[root@fosnix ~]# cd /tmp
[root@fosnix ~]# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
[root@fosnix ~]# tar -zxvf nagios-plugins-2.2.1.tar.gz
[root@fosnix ~]# cd /tmp/nagios-plugins-2.2.1/

Compile and install the Nagios plugins.

[root@fosnix ~]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@fosnix ~]# make
[root@fosnix ~]# make install

Start Nagios Server

Verify the sample Nagios configuration files.

[root@fosnix ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Output:

[root@fosnix ~]# Nagios Core 4.4.3
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-01-15
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

If there are no errors, then start the Nagios service.

[root@fosnix ~]# service nagios start

SELinux

IPut SELinux in Permissive mode or disable it.

[root@fosnix ~]# setenforce 0

To make this change permanent, you will have to modify /etc/selinux/config and reboot the system.

Firewall

Make sure to allow web server access through the firewall.

[root@fosnix ~]# ##
[root@fosnix ~]# firewall-cmd --permanent --add-service=http
[root@fosnix ~]# firewall-cmd --reload

Access Nagios Web Interface

Now access the Nagios web interface using the following URL. You’ll be prompted for the username (nagiosadmin) and password you specified earlier.

http://ip-add-re-ss/nagios/

Install Nagios 4.4.3 on CentOS 7 – Nagios Login Screen

Nagios console will look like below.

Install Nagios 4.4.3 on CentOS 7 – Nagios Portal

You may also like...

Leave a Reply

Your email address will not be published.