In this article, we will learn about how to install Nagios Core 4.3.3& Nagios Core plugins versions 2.2.1.
Nagios Core 4.3.3 is an Open source monitoring application tool that will monitor the Servers, Network firewalls, switches, and printers which also send notifications for the hosts, services and send notifications for the warning, critical levels send a notification once the services are hosts are recovered.
Nagios also provides the information on s single web interface and sends the notifications whenever there is a threshold according to the configuration we did for CPU utilization, Disk utilization which also supports for no of ports like HTTP, SNMP, ICMP, FTP, SSH, SMTP, POP3.
Installing the dependencies.
Before we proceed further we will first install all the dependencies packages like PHP, Apache, and other packages required to run the Nagios Core 4.2.1
[root@localhost ~]# yum install httpd php gcc glibc glibc-comman gd gd-devel make net-snmp unzip –y
Output:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iitm.ac.in
* extras: ftp.iitm.ac.in
* updates: mirrors.nhanhoa.com
Package httpd-2.4.6-67.el7.centos.5.x86_64 already installed and latest version
Package php-5.4.16-42.el7.x86_64 already installed and latest version
Package gcc-4.8.5-16.el7.x86_64 already installed and latest version
Package glibc-2.17-196.el7.x86_64 already installed and latest version
No package glibc-comman available.
Package gd-2.0.35-26.el7.x86_64 already installed and latest version
Package gd-devel-2.0.35-26.el7.x86_64 already installed and latest version
Package 1:make-3.82-23.el7.x86_64 already installed and latest version
Package 1:net-snmp-5.7.2-28.el7.x86_64 already installed and latest version
Package unzip-6.0-16.el7.x86_64 already installed and latest version
Resolving Dependencies
…
--> Processing Dependency: grub2-common = 1:2.02-0.64.el7.centos for package: 1:grub2-tools-2.02-0.64.el7.centos.x86_64
---> Package grub2-tools-efi.x86_64 1:2.02-0.64.el7.centos will be obsoleting
---> Package grub2-tools-extra.x86_64 1:2.02-0.64.el7.centos will be obsoleting
---> Package grub2-tools-minimal.x86_64 1:2.02-0.64.el7.centos will be obsoleting
---> Package grubby.x86_64 0:8.28-21.el7_3 will be updated
---> Package grubby.x86_64 0:8.28-23.el7 will be an update
---> Package gsettings-desktop-schemas.x86_64 0:3.14.2-1.el7 will be updated
---> Package gsettings-desktop-schemas.x86_64 0:3.22.0-1.el7 will be an update
---> Package gzip.x86_64 0:1.5-8.el7 will be updated
---> Package gzip.x86_64 0:1.5-9.el7 will be an update
---> Package haproxy.x86_64 0:1.5.18-3.el7_3.1 will be updated
Downloading packages:
(1/30): freetype-devel-2.4.11-15.el7.x86_64.rpm | 356 kB 00:00:00
(2/30): cpp-4.8.5-16.el7.x86_64.rpm | 5.9 MB 00:00:01
(3/30): gd-2.0.35-26.el7.x86_64.rpm | 146 kB 00:00:00
(4/30): gd-devel-2.0.35-26.el7.x86_64.rpm | 79 kB 00:00:00
(5/30): glibc-devel-2.17-196.el7.x86_64.rpm | 1.1 MB 00:00:00
(6/30): glibc-headers-2.17-196.el7.x86_64.rpm | 675 kB 00:00:00
(7/30): kernel-headers-3.10.0-693.2.2.el7.x86_64.rpm | 6.0 MB 00:00:00
(8/30): libX11-devel-1.6.5-1.el7.x86_64.rpm | 980 kB 00:00:00
(9/30): libXau-devel-1.0.8-2.1.el7.x86_64.rpm | 14 kB 00:00:00
(10/30): libXpm-3.5.12-1.el7.x86_64.rpm | 55 kB 00:00:00
(11/30): libXpm-devel-3.5.12-1.el7.x86_64.rpm | 36 kB 00:00:00
(12/30): fontconfig-devel-2.10.95-11.el7.x86_64.rpm | 128 kB 00:00:02
(13/30): libXt-1.1.5-3.el7.x86_64.rpm | 173 kB 00:00:00
(14/30): gcc-4.8.5-16.el7.x86_64.rpm | 16 MB 00:00:02
(15/30): libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm | 98 kB 00:00:00
(16/30): libpng-devel-1.5.13-7.el7_2.x86_64.rpm | 122 kB 00:00:00
(17/30): libmpc-1.0.1-3.el7.x86_64.rpm | 51 kB 00:00:00
(18/30): libxcb-devel-1.12-1.el7.x86_64.rpm | 1.0 MB 00:00:00
(19/30): libzip-0.10.1-8.el7.x86_64.rpm | 48 kB 00:00:00
(20/30): lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el….
….
Installed:
gcc.x86_64 0:4.8.5-16.el7 gd.x86_64 0:2.0.35-26.el7 gd-devel.x86_64 0:2.0.35-26.el7 net-snmp.x86_64 1:5.7.2-28.el7 php.x86_64 0:5.4.16-42.el7 unzip.x86_64 0:6.0-16.el7
Dependency Installed:
cpp.x86_64 0:4.8.5-16.el7 fontconfig-devel.x86_64 0:2.10.95-11.el7 freetype-devel.x86_64 0:2.4.11-15.el7
glibc-devel.x86_64 0:2.17-196.el7 glibc-headers.x86_64 0:2.17-196.el7 kernel-headers.x86_64 0:3.10.0-693.2.2.el7
libX11-devel.x86_64 0:1.6.5-1.el7 libXau-devel.x86_64 0:1.0.8-2.1.el7 libXpm.x86_64 0:3.5.12-1.el7
libXpm-devel.x86_64 0:3.5.12-1.el7 libXt.x86_64 0:1.1.5-3.el7 libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7
libmpc.x86_64 0:1.0.1-3.el7 libpng-devel.x86_64 2:1.5.13-7.el7_2 libxcb-devel.x86_64 0:1.12-1.el7
libzip.x86_64 0:0.10.1-8.el7 lm_sensors-libs.x86_64 0:3.4.0-4.20160601gitf9185e5.el7 mpfr.x86_64 0:3.1.1-4.el7
net-snmp-agent-libs.x86_64 1:5.7.2-28.el7 net-snmp-libs.x86_64 1:5.7.2-28.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7
php-cli.x86_64 0:5.4.16-42.el7 php-common.x86_64 0:5.4.16-42.el7 xorg-x11-proto-devel.noarch 0:7.7-20.el7
Complete!
Downloading the Nagios Core 4.3.2 Packages.
Once the dependencies are installed we will download the Nagios Core 4.3.3 and Nagios plugins 2.2.1 from the Nagios office repository.
Nagios Core 4.3.3
[root@localhost ~]# wget https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz
--2017-10-13 07:09:11-- https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz
Resolving sourceforge.net (sourceforge.net)... 216.34.181.60
Connecting to sourceforge.net (sourceforge.net)|216.34.181.60|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz/download [following]
--2017-10-13 07:09:12-- https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz/download
Connecting to sourceforge.net (sourceforge.net)|216.34.181.60|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://downloads.sourceforge.net/project/nagios/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz?r=&ts=1507892953&use_mirror=excellmedia [following]
--2017-10-13 07:09:13-- https://downloads.sourceforge.net/project/nagios/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz?r=&ts=1507892953&use_mirror=excellmedia
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://excellmedia.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz [following]
--2017-10-13 07:09:14-- https://excellmedia.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.3.4/nagios-4.3.4.tar.gz
Resolving excellmedia.dl.sourceforge.net (excellmedia.dl.sourceforge.net)... 202.153.32.19
Connecting to excellmedia.dl.sourceforge.net (excellmedia.dl.sourceforge.net)|202.153.32.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11096863 (11M) [application/x-gzip]
Saving to: ‘nagios-4.3.4.tar.gz’
100%[=======================================================================================================================================>] 11,096,863 319KB/s in 37s
2017-10-13 07:09:53 (295 KB/s) - ‘nagios-4.3.4.tar.gz’ saved [11096863/11096863]
Nagios Plugins 2.2.1
# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
--2017-10-13 07:10:38-- https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
Resolving nagios-plugins.org (nagios-plugins.org)... 72.14.186.43
Connecting to nagios-plugins.org (nagios-plugins.org)|72.14.186.43|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2728818 (2.6M) [application/x-gzip]
Saving to: ‘nagios-plugins-2.2.1.tar.gz’
100%[=======================================================================================================================================>] 2,728,818 1.44MB/s in 1.8s
2017-10-13 07:10:41 (1.44 MB/s) - ‘nagios-plugins-2.2.1.tar.gz’ saved [2728818/2728818]
Once the files are downloaded we will extract the files using the below command.
[root@localhost ~]# tar -zxpvf nagios-plugins-2.2.1.tar.gz
[root@localhost ~]# tar -zxvf nagios-4.3.4.tar.gz
Creating Nagios User and Group.
As we needed to create a user Nagios and a group called nagcmd for running the Nagios and give user permissions on the group and apache.
[root@localhost ~]# groupadd nagcmd
[root@localhost ~]# useradd nagios
[root@localhost ~]# passwd nagios
Changing password for user nagios.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# usermod -G nagcmd nagios
[root@localhost ~]# usermod -G nagcmd apache
Installing Nagios Core 4.3.3
Now we will install the Nagios Core 4.3.3 by changing the director to Nagios core install directory and running the below command.
[root@localhost ~]# cd nagios-4.3.4
[root@localhost nagios-4.3.4]# ./configure --with-command-group=nagcmd
./configure --with-command-group=nagcmd
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether make sets $(MAKE)... yes
checking whether ln -s works... yes
checking for strip... /usr/bin/strip
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
…
…
*** Configuration summary for nagios 4.3.2 2017-05-09 ***:
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: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
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.
Now we will compile the main programs using the below commands
[root@localhost nagios-4.3.4]# make all
cd ./base && make
make[1]: Entering directory `/root/nagios-4.3.4/base'
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nagios.o nagios.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o broker.o broker.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nebmods.o nebmods.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o ../common/shared.o ../common/shared.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nerd.o nerd.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o query-handler.o query-handler.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o workers.o workers.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o checks.o checks.c
..
..
make[1]: Leaving directory `/root/nagios-4.3.4/worker'
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install
- This installs the main program, CGIs, and HTML files
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
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
make install-exfoliation
- This installs the Exfoliation theme for the Nagios web interface
make install-classicui
- This installs the classic theme for the Nagios web interface
*** Support Notes *******************************************
If you have questions about configuring or running Nagios,
please make sure that you:
..
..
Once the Nagios files compete we needed to init scripts, make Nagios work from CLI, and also install some sample config files, a config web interface to run the Nagios from web browsers.
[root@localhost nagios-4.3.4]# make install-init
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
*** Init script installed ***
[root@localhost nagios-4.3.4]# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw
*** External command directory configured ***
[root@localhost nagios-4.3.4]# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg
*** Config files installed ***
Remember, these are *SAMPLE* config files. You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.
[root@localhost nagios-4.3.4]# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
if [ 0 -eq 1 ]; then \
ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \
fi
*** Nagios/Apache conf file installed ***
Once the web interface is installed and configured on the Apache we needed to create a default username we called it ‘nagiosadmin’ and create a password for the user herein demo purposes we will create the same as the username, below is the command to create the use and password for the user
[root@localhost 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
Configure the email alerts for sending Notifications from Nagios.
This is an optional step but if we can do it this will help us to get the notifications and email alerts if something goes wrong with the servers and machines we monitor. We needed to update the email id in the area where it is highlighted with red.
[root@localhost nagios-4.3.4]# vi /usr/local/nagios/etc/objects/contacts.cfg
###############################################################################
# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
#
#
# NOTES: This config file provides you with some example contact and contact
# group definitions that you can reference in host and service
# definitions.
#
# You don't need to keep these definitions in a separate file from your
# other object definitions. This has been done just to make things
# easier to understand.
#
###############################################################################
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################
# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.
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 nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
"/usr/local/nagios/etc/objects/contacts.cfg" 54L, 2138C
...
...
Nagios Plugins Installation.
Once the core is ready and configured we will now install the Nagios plugins
[root@localhost nagios-plugins-2.2.1]# ./configure --with-nagios-user=nagios --with-nagios-group=Nagios
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to disable maintainer-specific portions of Makefiles... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
..
..
configure: creating ./config.status
config.status: creating gl/Makefile
config.status: creating nagios-plugins.spec
config.status: creating tools/build_perl_modules
config.status: creating Makefile
config.status: creating tap/Makefile
config.status: creating lib/Makefile
config.status: creating plugins/Makefile
config.status: creating lib/tests/Makefile
config.status: creating plugins-root/Makefile
config.status: creating plugins-scripts/Makefile
config.status: creating plugins-scripts/utils.pm
config.status: creating plugins-scripts/utils.sh
config.status: creating perlmods/Makefile
config.status: creating test.pl
config.status: creating pkg/solaris/pkginfo
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
[root@localhost nagios-plugins-2.2.1]# make
[root@localhost nagios-plugins-2.2.1]# make install
Verifying the Nagios Configuration files
Once the plugins are installed we will verify the Nagios configuration to make sure that everything is working fine needed to restart the Nagios daemon.
[root@localhost nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.3.3
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2017-05-09
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 we have not found any errors or warnings we will restart the Nagios & httpd and enable them to start at the server startup.
[root@localhost nagios-plugins-2.2.1]# systemctl restart nagios
[root@localhost nagios-plugins-2.2.1]# systemctl restart httpd
[root@localhost nagios-plugins-2.2.1]# systemctl enable nagios
nagios.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig nagios on
[root@localhost nagios-plugins-2.2.1]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Nagios Web-interface.
As everything is configured we will now check the web interface of Nagios using the user ‘nagiosadmin’.
Access the web browser using the URL http://IP-Address/nagios
Login Page.

Home Page for Nagios Core 4.3.4

Nagios HOSTS page

Nagios Services Page

In the above article we have learned about how to install the Nagios Core 4.3.4, Nagios Plugins 2.2.1, created Nagios admin user, init, web-interface, etc.