How to install Nagios Core 4.3.2 on CentOS
How to install Nagios Core 4.3.2 on CentOS 6
Nagios is a open source monitoring server used to monitor host and services etc. Before installaing, visit the Nagios official website https://www.nagios.org/ for latest version of Nagios core and download the tar package. Before installing the Nagios on the target server, check whether LAMP environment is already installed or not. Now install some of the required packages for compiling and installing Nagios from it’ s source code. So the target system must contain some compliers in order to compile Nagios source. This tutorial explains the installation procedure of Nagios core 4.3.2 on CentOS 6.
To know more about the configuration procedure of Apache plugins in Nagios server, visit
https://www.linuxhelp.com/how-to-configure-apache-plugins-in-nagios-server/
Installation procedure
To start with the installation process, execute the following command to install the dependency packages and press y to continue with the installation procedure.
[root@nagios ~]# yum install gcc glibc glibc-common gd gd-devel net-snmp -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-18.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
.
.
.
headers.x86_64 0:2.12-1.209.el6_9.1 libX11.x86_64 0:1.6.4-3.el6 libX11-common.noarch 0:1.6.4-3.el6 libgcc.x86_64 0:4.4.7-18.el6 libgomp.x86_64 0:4.4.7-18.el6
libxcb.x86_64 0:1.12-4.el6 net-snmp-libs.x86_64 1:5.5-60.el6
Complete!
The dependency packages are installed. Create user and group for Nagios and then add apache and Nagios user to Nagios group by running the following command.
[root@nagios ~]# useradd nagios [root@nagios ~]# passwd nagios Changing password for user nagios. New password: BAD PASSWORD: it is WAY too short BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully. [root@nagios ~]# groupadd nagcmd [root@nagios ~]# usermod -a -G nagcmd nagios [root@nagios ~]# usermod -a -G nagcmd apache
Go to the download folder where the downloaded Nagios tarball package is located and extract the package by executing the following tar command.
[root@nagios ~]# ls anaconda-ks.cfg Desktop Documents Downloads install.log install.log.syslog Music nagios-4.3.2.tar.gz Pictures Public Templates Videos [root@nagios ~]# tar -xzvf nagios-4.3.2.tar.gz nagios-4.3.2/ nagios-4.3.2/.gitignore nagios-4.3.2/Changelog nagios-4.3.2/INSTALLING nagios-4.3.2/LEGAL nagios-4.3.2/LICENSE nagios-4.3.2/Makefile.in nagios-4.3.2/README nagios-4.3.2/README.asciidoc nagios-4.3.2/THANKS nagios-4.3.2/UPGRADING . . . nagios-4.3.2/xdata/xodtemplate.h nagios-4.3.2/xdata/xpddefault.c nagios-4.3.2/xdata/xpddefault.h nagios-4.3.2/xdata/xrddefault.c nagios-4.3.2/xdata/xrddefault.h nagios-4.3.2/xdata/xsddefault.c nagios-4.3.2/xdata/xsddefault.h
Now move to extracted directory to compile and install the extracted package.
[root@nagios ~]# cd nagios-4.3.2
[root@nagios nagios-4.3.2]# ./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...
.
.
.
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
Review the options above for accuracy. If they look okay,
The package has been compiled. Now type ' make all' command to compile the main program and CGIs.
[root@nagios nagios-4.3.2]# make all
cd ./base & & make
make[1]: Entering directory `/root/nagios-4.3.2/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
.
.
.
before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you. This might include:
- What version of Nagios you are using
- What version of the plugins you are using
- Relevant snippets from your config files
- Relevant error messages from the Nagios log file
For more information on obtaining support for Nagios, visit:
https://support.nagios.com
*************************************************************
Enjoy.
Next execute the make install and make-init command to install the package in the target system.
[root@nagios nagios-4.3.2]# make install cd ./base & & make install make[1]: Entering directory `/root/nagios-4.3.2/base' make install-basic make[2]: Entering directory `/root/nagios-4.3.2/base' /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin /usr/bin/install -c -m 774 -o nagios -g nagios nagios /usr/local/nagios/bin /usr/bin/install -c -m 774 -o nagios -g nagios nagiostats /usr/local/nagios/bin make[2]: Leaving directory `/root/nagios-4.3.2/base' make strip-post-install . . . 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 make[1]: Leaving directory `/root/nagios-4.3.2' [root@nagios nagios-4.3.2]# 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 ***
Then, execute the install-config command to install the required configuration files.
[root@nagios nagios-4.3.2]# 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
.
.
.
*** 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.
Execute the make-install commandmode to install and configure the permissions on the directory for holding the external command file. And also execute the make-install webconf command to install and configure the webconf file in Nagios.
[root@nagios nagios-4.3.2]# 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@nagios nagios-4.3.2]# 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 ***
Create the Nagios web user interface and also password.
[root@nagios nagios-4.3.2]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
Once the credentials have been added. Restart the apache service by executing the following command.
[root@nagios nagios-4.3.2]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Now download the Nagios plugins tarball package by running the following command.
[root@nagios nagios-4.3.2]# cd
[root@nagios ~]# wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
--2017-05-19 00:45:16-- http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
Resolving nagios-plugins.org... 72.14.186.43
Connecting to nagios-plugins.org|72.14.186.43|:80... 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 33.2K/s in 71s
2017-05-19 00:46:28 (37.5 KB/s) - “ nagios-plugins-2.2.1.tar.gz” saved [2728818/2728818]
Extract the Nagios plugin package by executing the following tar command.
[root@nagios ~]# tar -xzvf nagios-plugins-2.2.1.tar.gz
nagios-plugins-2.2.1/
nagios-plugins-2.2.1/perlmods/
nagios-plugins-2.2.1/perlmods/Config-Tiny-2.14.tar.gz
nagios-plugins-2.2.1/perlmods/parent-0.226.tar.gz
nagios-plugins-2.2.1/perlmods/Test-Simple-0.98.tar.gz
nagios-plugins-2.2.1/perlmods/Makefile.in
nagios-plugins-2.2.1/perlmods/version-0.9903.tar.gz
nagios-plugins-2.2.1/perlmods/Makefile.am
.
.
.
nagios-plugins-2.2.1/pkg/solaris/preinstall
nagios-plugins-2.2.1/pkg/solaris/solpkg
nagios-plugins-2.2.1/pkg/solaris/pkginfo.in
nagios-plugins-2.2.1/pkg/solaris/pkginfo
nagios-plugins-2.2.1/pkg/redhat/
nagios-plugins-2.2.1/pkg/redhat/requires
Install the Nagios plugins in the Nagios folder by running the following command.
[root@nagios ~]# cd nagios-plugins-2.2.1 [root@nagios 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... /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 . . . 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
Execute the make command to start the installation process.
[root@nagios nagios-plugins-2.2.1]# make
make all-recursive
make[1]: Entering directory `/root/nagios-plugins-2.2.1'
Making all in gl
make[2]: Entering directory `/root/nagios-plugins-2.2.1/gl'
rm -f alloca.h-t alloca.h & &
{ echo ' /* DO NOT EDIT! GENERATED AUTOMATICALLY! */'
cat ./alloca.in.h
} > alloca.h-t & &
.
.
.
make[2]: Leaving directory `/root/nagios-plugins-2.2.1/po'
make[2]: Entering directory `/root/nagios-plugins-2.2.1'
make[2]: Leaving directory `/root/nagios-plugins-2.2.1'
make[1]: Leaving directory `/root/nagios-plugins-2.2.1'
Execute the make-install command to install and configure the required directory.
[root@nagios nagios-plugins-2.2.1]# make install
Making install in gl
make[1]: Entering directory `/root/nagios-plugins-2.2.1/gl'
make install-recursive
make[2]: Entering directory `/root/nagios-plugins-2.2.1/gl'
make[3]: Entering directory `/root/nagios-plugins-2.2.1/gl'
.
.
.
make[2]: Entering directory `/root/nagios-plugins-2.2.1'
make[2]: Nothing to be done for `install-exec-am' .
make[2]: Nothing to be done for `install-data-am' .
make[2]: Leaving directory `/root/nagios-plugins-2.2.1'
make[1]: Leaving directory `/root/nagios-plugins-2.2.1'
Next verify the Nagios configuration by executing the following command.
[root@nagios nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.3.2
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
To start and enable Nagios daemons, run the following commands.
[root@nagios nagios-plugins-2.2.1]# service nagios start Starting nagios: done. [root@nagios nagios-plugins-2.2.1]# chkconfig nagios on
Open the browser and call Nagios web interface with the target system' s ip address followed by Nagios directory like http://192.168.5.161/nagios and run it.
Wasn' t that an easy installation procedure? Nagios also detects the protocol failures and network outages.
Comments ( 1 )