Steps to install Nagios core on Debian 8 Jessie
Install Nagios Core on Debian
Nagios Core is free open-source application that would be used to monitor the health of the server.
By default Nagios monitor below services
- Current CPU Usage
- Current Load
- Current Users
- Data Partition
- Root Partition
- Swap Usage
- Total Processes
- Zombie Processes
In this tutorial, we will learn to install and configure the official version of the Nagios core on the Debian 8 Jessie server.
To check the basic installation steps, we are going to install the Nagios core and nagios NRPE plugin on the same system and monitor the services of the same server.
As you know Nagios monitoring is a very vast topic not possible to explain in a single article so what we decide to explain to you complete Nagios which we need in the Live environment in several parts.
It helps you to understand the Nagios Monitoring in more detail and easily.
I have used below server configuration to install nagios core,
- CPU: 2 Core
- RAM: 4 GB
- Storage: 20 GB
- OS: Debian GNU/Linux 8.5 (Jessie)
- IP Address: 192.168.3.39
Install Nagios Core
Step 1: Install Pre-requirements for Nagios
Before start installing Nagios core, we need to install dependant packages that are required for nagios core.
$ apt-get update
$ apt-get install build-essential apache2 php5 openssl perl make php5-gd libgd2-xpm-dev libapache2-mod-php5 libperl-dev libssl-dev daemon wget apache2-utils
Step 2: Create User & Group
Now we need one user and group which has rights or permissions to access Nagios files.
For allowing the external commands to be executed through the web interface we add Nagios user and apache user in the “nagioscmd group”.
Run below commands to create user and group,
$ useradd nagios
$ groupadd nagioscmd
Run below command to add Nagios user and apache user under the nagioscmd group,
$ usermod -a -G nagioscmd nagios
$ usermod -a -G nagioscmd www-data
Step 3: Download the Nagios Core
Download the latest version Nagios core server from the official site inside the “/opt” directory and compile the Nagios core from downloaded source code.
$ cd /opt/
$ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
$ tar -xvf nagios-4.1.1.tar.gz
$ cd /opt/nagios-4.1.1
$ ./configure –with-nagios-group=nagios –with-command-group=nagioscmd –with-httpd_conf=/etc/apache2/sites-enabled/
$ make all
$ make install
$ make install-init
$ make install-config
$ make install-commandmode
$ make install-webconf
Step 4: Configure the Nagios Server
All the configuration files of Nagios have been installed in “/usr/local/nagios/etc/”. whenever you want to make any Nagios configuration changes you need to check for that “.cfg” file under “/usr/local/nagios/etc/”.
Now we need to make one change in “contacts.cfg “file before proceeding..
Edit “/usr/local/nagios/etc/objects/contacts.cfg” file and changed the email id with your email id to receive the Alerts.
alias Nagios Admin ;
email [email protected];
Step 5: Configure Nagios Web Interface
In this step, we are going to give password protection for Nagios web interface using below command,
$ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosuser
Make sure you note down the password because we need it later when using the Nagios web interface.
Step 6: Enable CGI Module in Apache
Run below command to enable the cgi module,
$ a2enmod cgi
$ service apache2 restart
Step 7: Apache Virtualhost Configuration
We have already installed the apache package in our first step and here we are setting up the virtual host so that we would be able to browse the Nagios core in the browser.
You can read more about Apache installation from the below link,
Step 8: Restart the Apache Service
Once the configuration is done restart the apache server.
$ service apache2 restart
We have done the Nagios Core installation here.
Nagios NRPE Client installation and Configuration
NRPE (Nagios Remote Plugin Executor) Client plugin allows you to monitor any remote Linux/Unix services or network devices. This NRPE add-on allows Nagios to monitor any local resources like CPU load, Swap, Memory usage, Online users, etc. on remote Linux machines. After all, these local resources are not mostly exposed to external machines, an NRPE agent must be installed and configured on the remote machines.
Step 1: Install NRPE Package
First, we would be installing the NRPE package with the help of the apt-get command.
$ apt-get install nagios-nrpe-server
Step 2: Download the Nagios Plugin
Download the Nagios-plugins using “wget command” on the system. These plugins are helping us to monitor the system.
$ wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
$ tar -xvf nagios-plugins-2.0.3.tar.gz
$ cd nagios-plugins-2.0.3/
$ ./configure –with-nagios-user=nagios –with-nagios-group=nagioscmd
$ make install
Step 3: Configure NRPE (nrpe.cfg file)
Open the file nrpe.cfg which basically resides under the “/etc/nagios/” directory. This file is the main configuration file of NRPE which is used to define the plugins to monitor the host.
#You will find default plugins are enabled to monitor the localhost.#
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
Save and close the file. That’s it.
Step 4: Give Access Rights to Nagios User
Currently, the web interface not able to access the host for a monitor.
For this, we need to provide access or permission to our user to fetch info from the server.
Open “cgi.cfg file” which is resides under “/usr/local/nagios/etc” and add new username next to nagiosadmin using comma.
Save and close the file.
Step 5: Restart the Nagios and NRPE Service
Test your configuration changes with below command and then restart NRPE and Nagios service.
Below command check your complete Nagios configuration and provides you warnings and errors so before restarting Nagios service always run this command,
$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
$ /etc/init.d/nagios restart && /etc/init.d/nagios-nrpe-server restart
If you’re facing any difficulties while adding installing Nagios. Please do comment on your queries or problem via the comment section, till then stay tuned to Linuxgrow.com for more such valuable articles.