Installing Nagios 4.0.1 and Nagios Plugin 1.5

Installing Nagios 4.0.1 and Nagios Plugin 1.5

  • Nagios and its plugins will be installed under /usr/local/nagios directory.
  • Nagios will be configured to monitor few services of your local machine (Disk Usage, CPU Load, Current Users, Total Processes, etc.)
  • Nagios web interface will be available at http://localhost/nagios

Step 1: Install Required Dependencies

We need to install Apache, PHP and some libraries like gcc, glibc, glibc-common and GD libraries and its development libraries before installing Nagios 4.0.1 with source. And to do so we can use yum default package installer.

# yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp

# firewall-cmd –add-service=http –permanent

# firewall-cmd –reload

Step 2: Create Nagios User and Group

Create a new nagios user and nagcmd group account and set a password

# useradd nagios# groupadd nagcmd

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

#usermod -G nagcmd nagios#usermod -G nagcmd apache

Step 3: Download Nagios Core 4.0.1 and Nagios Plugin 1.5

Create a directory for your Nagios installation and all its future downloads.

# mkdir /root/nagios# cd /root/nagios

Now download latest Nagios Core 4.0.1 and Nagios plugins 1.5 packages with wget command.

# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.1.tar.gz# wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

Step 4: Extract Nagios Core and its Plugins

We need to extract downloaded package with tar command as follows.

# tar –xvf nagios-4.0.1.tar.gz# tar –xvf nagios-plugins-1.5.tar.gz

When you extract these tarballs with tar command, two new folders will appear in that directory.

# ll

Configure Nagios Core

Now, first we will configure Nagios Core and to do so we need to go to Nagios directory and run configure file and if everything goes fine, it will show the output in the end as sample output. Please see below.

# cd nagios-4.0.1# ./configure –with-command-group=nagcmd

Sample output:

Now, after configuring we need to Compile and install all the binaries with make command and make install command will install all the needed libraries in your machine and we can proceed further.

# make all# make install

Sample output:

Following command will install the init scripts for Nagios.

# make install-init

To make nagios work from command line we need to install command-mode.

# make install-commandmode

Next, install sample nagios files, please run following command.

# make install-config

Sample output:

Step 5: Customizing Nagios Configuration

Open the “contacts.cfg” file with your choice of editor and set the email address associated with the nagiosadmin contact definition to receiving email alerts.

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

Sample Output

Step 6: Install and Configure Web Interface for Nagios

We are done with all configuration in the backend, now we will 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”.

# make install-webconf

In this step, we will be creating a password for “nagiosadmin”. After executing this command, please provide a password twice and keep it remember because this password will be used when you login in the Nagios Web interface.

# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.

# service httpd start# systemctl start httpd.service

Step 7: Compile and Install Nagios Plugin

We have downloaded nagios plugins in /root/nagios, Go there and configure and install it as directed below.

# cd /root/nagios# cd nagios-plugins-1.5# ./configure –with-nagios-user=nagios –with-nagios-group=nagios# make install

Step 8: Verify Nagios Configuration Files

Now we are all done with Nagios configuration and its time to verify it and to do so please insert following command. If everything goes smooth it will show up similar to below output.

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Sample Output

Step 9: Add Nagios Services to System Startup

To make Nagios work across reboots, we need to add nagios and httpd with chkconfig command.

# chkconfig –add nagios# chkconfig –level 35 nagios on# chkconfig –add httpd# chkconfig –level 35 httpd on

Restart Nagios to make the new settings take effect.

# service nagios start# systemctl start nagios.service

Step 10: Login to the Nagios Web Interface

Your nagios is ready to work, please open it in your browser with “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password.

Nagios Login

Nagios Login

Host View

Nagios Host View

Nagios Overview

Nagios Overview

Service View

Nagios Services

Process View

Nagios Process View

Upgrade Nagios 3.x to Nagios 4.0.1

If you are already running an older version of Nagios, you can upgrade it anytime. To do so, you just need to download the latest tar archive of it and configure it as shown below.

# service nagios stop# tar –zxvf nagios-4.0.1.tar.gz# cd nagios-4.0.1# ./configure# make all# make install# service nagios start

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *