Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Install and Configure Nagios 4 on CentOS 7

Introduction

Nagios, now known as Nagios Core, is a free and Open Source monitoring tool, that monitors systems, networks and infrastructure.
With Nagios, you can monitor your remote hosts and their services remotely on a single window. It shows warnings and indicates if something goes wrong in your servers which eventually helps us to detect some problems before they occur. It helps us to reduce downtime.

In this tutorial, we will cover the installation of Nagios 4, a very popular open source monitoring system, on CentOS 7.

Install & Configure Nagios 4 on CentOS 7

1. Install Prerequisites and Dependencies
We need to install LAMP stack (i.e. Linux, Apache, MySQL, PHP) and some libraries like gccglibcglibc-common and GD libraries and its development libraries before installing Nagios 4.

[root@devopstechie ~]$ yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

2. Create Nagios User and Group
Create a new “nagios” user and “nagcmd” group account and set a password.

[root@devopstechie ~]$ useradd nagios
[root@devopstechie ~]$ groupadd nagcmd

Next, add both the nagios user and the apache user to the nagcmd group.

[root@devopstechie ~]$ usermod -G nagcmd nagios
[root@devopstechie ~]$ usermod -G nagcmd apache

3. Download and Extract Nagios Core
Download the source code for the latest stable release of Nagios Core.Go to the Nagios downloads page, and click the Skip to download link below the form. Copy the link address for the latest stable release so you can download it to your Nagios server.

[root@devopstechie ~]$ mkdir -p /opt/nagios
[root@devopstechie ~]$ cd /opt/nagios
[root@devopstechie nagios]$ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
[root@devopstechie nagios]$ tar -xvf nagios-4.3.4.tar.gz

4. Configure Nagios Core (Backend)
Now, configure Nagios Core and to do so we need to go to Nagios directory and run configure file

[root@devopstechie nagios]$ cd nagios-4.3.4/
[root@devopstechie nagios-4.3.4]$ ./configure --with-command-group=nagcmd

After configuring, we need to compile and install all the binaries with following commands,

[root@devopstechie nagios-4.3.4]$ make all

Now we can run these make commands to install Nagios, init scripts, and sample configuration files,

[root@devopstechie nagios-4.3.4]$ make install
[root@devopstechie nagios-4.3.4]$ make install-init
[root@devopstechie nagios-4.3.4]$ make install-commandmode
[root@devopstechie nagios-4.3.4]$ make install-config

**** The above commands does the following installation ****
make install-init
- This installs the init script in /etc/rc.d/init.d

make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file

make install-config
- This installs sample config files in /usr/local/nagios/etc
**** The above commands does the following installation ****

5. Configure Nagios Core (Web Interface)
After done with all configuration in the backend, now need to configure Web Interface For Nagios with following command.  The below command will Configure Web interface for Nagios and a web admin user will be created “nagiosadmin”.

[root@devopstechie nagios-4.3.4]$ make install-webconf

Now, time to set a password for “nagiosadmin”. After executing following command, please provide a password twice and keep it remember because this password will be used when you login in the Nagios Web interface.

[root@devopstechie nagios-4.3.4]$ htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Install & Configure Nagios Plugins on CentOS 7

1. Download and Extract Nagios Plugins
Download the source code for the latest stable release of Nagios Plugins.

[root@devopstechie ~]$ cd /opt/nagios
[root@devopstechie nagios]$ wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
[root@devopstechie nagios]$ tar -xvf nagios-plugins-2.2.1.tar.gz

2. Configure and install Nagios Plugins
Compile and install nagios plugins

[root@devopstechie nagios]$ cd nagios-plugins-2.2.1/
[root@devopstechie nagios]$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@devopstechie nagios]$ make
[root@devopstechie nagios]$ make install

Verify & Start Nagios

Now we are all done with Nagios configuration and its time to verify it,

[root@devopstechie nagios]$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Add Nagios Services to System Startup and Start

[root@devopstechie nagios]$ systemctl enable nagios

Restart Nagios

[root@devopstechie nagios]$ systemctl start nagios.service

Nagios Web Dashboard

That’s it about installation and configuration of nagios on centos 7, You’ve just begin your journey into monitoring.

Follow Me:

The post Install and Configure Nagios 4 on CentOS 7 appeared first on DevOps Techie.



This post first appeared on Devops Techie - Solutios For Devops Tools And Practices, please read the originial post: here

Share the post

Install and Configure Nagios 4 on CentOS 7

×

Subscribe to Devops Techie - Solutios For Devops Tools And Practices

Get updates delivered right to your inbox!

Thank you for your subscription

×