Nagios 4.1.1: Nagios Core 4.1.1 Installation on Centos 6.7
Nagios Core 4.1.1
This is a guide on installing the latest Nagios Core (4.1.1) on Centos 6.7. 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 the yum default package installer.
#
yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp
perl-rrd xinetd openssl-devel package perl-GD* ntp perl-rrd*
Step 2: Create Nagios User and Group so that application will configure the server perfectly.
Create a new "
# useradd nagios
# groupadd nagcmd
Next, add both the
Step 3: Add both the nagios user and the apache user to the nagcmd group.
#
usermod -G nagcmd nagios
# usermod -G
nagcmd www-data (for some if www-data is not theere use apache)
Step 4: Download Nagios Core 4.0.1 and Nagios Plugin 1.5
Create a directory for your
#
mkdir /root/nagios
# cd /root/nagios
Nowdownload latest Nagios Core 4.1.1 and the Nagios plugins 2.1.1 packages from the below Links
Nagios 4.1.1 Core Software Download and Installation:
# wget
http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.1.1.tar.gz
Nagios Plugins:
# wget https://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
Step 5: Installting Nagios Core
We need to extract downloaded package with tar command as follows.
# tar –xvf nagios-4.1.1.tar.gz
When you extract these tar files with tar command, two new folders will appear in that directory.
Step 6: Configure & Install Nagios Core Server Components
#
#. /configure
--prefix=/usr/local/nagios --with-nagios -user=nagios
--with-nagios -group=nagios
--with-command-user=nagios --with-command-group=nagcmd
Output:
General Options:
-------------------------
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
Apache conf . d
directory: /etc/httpd/conf. d
Mail program: /usr/bin/mail
Host OS: nagios.test.com
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL:
http://localhost/nagios/cgi-bin/
Review the options above for accuracy. If they look okay,
*** Main program, CGIs and HTML files
installed ***
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
Output:
You can continue with installing Nagios as follows (type '
- This installs the init script in
/etc/rc.d/init . d
- This installs and configures
permissions on the
- This installs sample config files in
/usr/local/nagios /etc
#
make install-init
To make nagios work
from the command line we need to install command-mode.
# make
install-commandmode
Next, install
sample nagios files,
please run following command.
# 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
Step 8: Install and Configure Web Interface for Nagios
We are done with all configurations in the
#
make install-webconf
In this step, we will be creating a password for “
#
htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new
password:
Adding
password for user nagiosadmin
Step 9: Restart Apache to make the new settings take effect.
#
service httpd start
Step 10: Configure and Install Nagios Plugin
We have downloaded
# cd /root/nagios
# cd tar
–xvf nagios -plugins-2.1.1. tar. gz
# ./configure --with-nagios -user=nagios
--with-nagios -group=nagios
--with-openssl=/usr/bin/openssl --enable-perl -modules
--enable-libtap
# make
# make install
Step 11: Verify Nagios Configuration Files
Now we are all done with Nagios configuration and its time to verify it and to do so please insert
/usr/local/nagios /bin/nagios -v
/usr/local/nagios /etc/nagios.cfg
Copyright (c)
2009-present Nagios Core Development Team and Community Contributors
Copyright (c)
1999-2009 Ethan Galstad
Last Modified:
08-19-2015
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 7 services.
Checked 1 hosts .
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 7 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 1 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
Step 12: Restart the Nagios services.
#
service nagios restart
To make Nagios
work across reboots, we need to add nagios and httpd with chkconfig command.
# c hkconfig --add nagios
# chkconfig
--level 35 nagios on
# chkconfig
--add httpd
# chkconfig
--level 35 httpd on
Step 13: Login to the Nagios Web Interface http://yourhostip/nagios
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.
Download and Install NRPE
NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent addons , so you can execute scripts and check metrics on remote Windows machines as well.
Step 14: First we needed to create the right folders:
#
mkdir -p /usr/local/src/nrpe
# wget
http://kent.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
Because of an
issue with the openssl library
folder we need to use another path than /usr/lib:
Now make and make
install:
#
make all
# make
install-plugin
# make
install-xinetd
Next, open /etc/services file add the following entry for the NRPE daemon at the bottom of the file.
# vi /etc/services
Restart the xinetd service.
#
service xinetd restart
Step
15: Verify NRPE Daemon Locally
Run the following command to verify the NRPE daemon working
correctly under xinetd .
# netstat -at | grep nrpe
Step 16: Verify the NRPE daemon is functioning properly.
#
/usr/local/nagios /libexec/check_nrpe
-H localhost
Output: ( Which shows the NRPE version)
NRPE v2. 15
Now we needed to create two configuration files so that we can monitor Linux or Unix machines
Step 17: To add the host:
# cd /usr/local/nagios /etc
# vi /usr/local/nagios /etc /hosts.cfg
check_period
24x7
check_interval
5
retry_interval
1
max_check_attempts
10
heck_command
check-host-alive
notification_period
24x7
notification_interval
30
notification_options
d, r
contact_groups
admins
}
host_name
Testbox
; The
name we're giving to this server
}
Step 18 To add the services:
# vi /usr/local/nagios /etc /services.cfg
define service{
use
generic-service
host_name
Testbox
service_description
CPU Load
check_command
check_nrpe! check_load
}
define service{
use
generic-service
host_name
Testbox
service_description Total Processes
check_command
check_nrpe! check_total_procs
}
define service{
use
generic-service
host_name
Testbox
service_description Current Users
check_command
check_nrpe! check_users
}
define service{
use
generic-service
host_name
Testbox
service_description Root Partition
check_command
check_nrpe! check_disk
}
define service{
use
generic-service
host_name
Testbox
service_description Home Partition
check_command
check_nrpe! check_disk_home
}
define service{
use
generic-service
host_name
Testbox
service_description Ping Status
check_command
check_ping! 10.0,80%! 50.0,90%
}
We needed to added this configuration files in nagios.cfg
#
cfg_file=/usr/local/nagios /etc /hosts.cfg
cfg_file=/usr/local/nagios /etc /services.cfg
Now NRPE commands should definition needs to be created in commands.cfg file.
# vi /usr/local/nagios /etc/objects/commands.cfg
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Finally, verify Nagios Configuration files for any errors.
#/usr/local/nagios /bin/nagios -v
/usr/local/nagios /etc/nagios.cfg
#
service nagios restart
Now your Nagios server is ready to monitor Linux machines
Adding MRTG to Nagios Core 4.1.1
Adding Nagios Graph to Nagios core 4.1.1
Fixing thenagios could not find the file nagios . cmd
Keywords: Nagios Core 4.1.1, Nagios Server, Nagios Monitoring Server, Minitor Basic services on Liunx, Linux Monitoring Server
Adding Nagios Graph to Nagios core 4.1.1
Fixing the
Keywords: Nagios Core 4.1.1, Nagios Server, Nagios Monitoring Server, Minitor Basic services on Liunx, Linux Monitoring Server
article about how to add network switch would be appreciated.
ReplyDelete