NAGIOS Installation
NAGIOS Installation
NAGIOS Installation
Prerequisites
During portions of the installation you'll need to have root access to your machine.
Make sure you've installed the following packages on your Fedora installation before continuing.
Apache
PHP
GCC compiler
GD development libraries
You can use yum to install these packages by running the following commands (as root):
/usr/sbin/useradd -m nagios
passwd nagios
Create a new nagcmd group for allowing external commands to be submitted through the web
interface. Add both the nagios user and the apache user to the group.
/usr/sbin/groupadd nagcmd
Download the source code tarballs of both Nagios and the Nagios plugins (visit
http://www.nagios.org/download/ for links to the latest versions). These directions were tested
with Nagios 3.1.1 and Nagios Plugins 1.4.11.
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-
3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-
plugins-1.4.11.tar.gz
Note: On Red Hat, the ./configure command mentioned above did not work and was hanging at
the when it was displaying the message: checking for redhat spopen problem… Add –enable-
redhat-pthread-workaround to the ./configure command as a work-around for the above problem
as shown below.
7. Start Nagios
[root@localhost]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-
flight check
Following three steps will happen on a very high level when Nagios (installed on the nagios-
servers) monitors a service (for e.g. disk space usage) on the remote Linux host.
1. Nagios will execute check_nrpe command on nagios-server and request it to monitor disk
usage on remote host using check_disk command.
2. The check_nrpe on the nagios-server will contact the NRPE daemon on remote host and
request it to execute the check_disk on remote host.
3. The results of the check_disk command will be returned back by NRPE daemon to the
check_nrpe on nagios-server.
Nagios Server (check_nrpe) —–> Remote host (NRPE deamon) —–> check_disk
Nagios Server (check_nrpe) <—– Remote host (NRPE deamon) <—– check_disk (returns
disk space usage)
nagios-plugins-1.4.11.tar.gz
nrpe-2.12.tar.gz
3. Install nagios-plugin
[remotehost]# cd /home/downloads
[remotehost]# tar xvfz nagios-plugins-1.4.11.tar.gz
[remotehost]# cd nagios-plugins-1.4.11
[remotehost]# export LDFLAGS=-ldl
4. Install NRPE
[remotehost]# cd /home/downloads
[remotehost]# tar xvfz nrpe-2.12.tar.gz
[remotehost]# cd nrpe-2.12
[remotehost]# ./configure
[remotehost]# make all
[remotehost]# make install-plugin
[remotehost]# make install-daemon
[remotehost]# make install-daemon-config
[remotehost]# make install-xinetd
Modify the /etc/xinetd.d/nrpe to add the ip-address of the Nagios monitoring server to the
only_from directive. Note that there is a space after the 127.0.0.1 and the nagios
monitoring server ip-address (in this example, nagios monitoring server ip-address is:
192.168.1.2)
Modify the /etc/services and add the following at the end of the file.
The nrpe.cfg file located on the remote host contains the commands that are needed to check the
services on the remote host. By default the nrpe.cfg comes with few standard check commands
as samples. check_users and check_load are shown below as an example.
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c
30,25,20
In all the check commands, the “-w” stands for “Warning” and “-c” stands for “Critical”. for e.g.
in the check_disk command below, if the available disk space gets to 20% of less, nagios will
send warning message. If it gets to 10% or less, nagios will send critical message. Change the
value of “-c” and “-w” parameter below depending on your environment.
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p
/dev/hda1
Note: You can execute any of the commands shown in the nrpe.cfg on the command line on
remote host and see the results for yourself. For e.g. When I executed the check_disk command
on the command line, it displayed the following:
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_http]=/usr/local/nagios/libexec/check_http -H 127.0.0.1 -w 5 -c 10
General Options:
————————-
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios
Note: I got the “checking for SSL headers… configure: error: Cannot find ssl headers” error
message while performing ./configure. Install openssl-devel as shown below and run the
./configure again to fix the problem.
[nagios-server]#/usr/local/nagios/libexec/check_nrpe -H 192.168.1.3
NRPE v2.12
Note: 192.168.1.3 in the ip-address of the remotehost where the NRPE and nagios plugin was
installed as explained in Section II above.
host_name server40 ; This host definition will inherit all variables that are defined
alias server40 ; in (or inherited by) the linux-server host template definition.
address 10.10.12.40
}
define service{
use generic-service
service_description Root Partition
contact_groups admins
check_command check_nrpe!check_disk
}
Restart the nagios as shown below and login to the nagios web (http://nagios-server/nagios/) to
verify the status of the remotehost linux sever that was added to nagios for monitoring.
I. Overview
II. 4 steps to install nagios on remote windows host
I. Overview
.
Following three steps will happen on a very high level when Nagios (installed on the nagios-
server) monitors a service (for e.g. disk space usage) on the remote Windows host.
1. Nagios will execute check_nt command on nagios-server and request it to monitor disk usage on
remote windows host.
2. The check_nt on the nagios-server will contact the NSClient++ service on remote windows host
and request it to execute the USEDDISKSPACE on the remote host.
3. The results of the USEDDISKSPACE command will be returned back by NSClient++ daemon to the
check_nt on nagios-server.
(3) Select Installation option and location. Use the default option and click next.
(4) Ready to Install Screen. Click on Install to get it started.
Go to Control Panel -> Administrative Tools -> Services. Double click on the “NSClientpp
(Nagios) 0.3.1.14 2008-03-12 w32″ service and select the check-box that says “Allow service to
interact with desktop” as shown below.
3. Modify the NSC.ini
(1) Modify NSC.ini and uncomment *.dll: Edit the C:\Program Files\NSClient++\NSC.ini file
and uncomment everything under [modules] except RemoteConfiguration.dll and CheckWMI.dll
[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
; You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; * *
; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S *
; * *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION
ENVIROMNEMTS!
;RemoteConfiguration.dll
; NSCA Agent is a new beta module use with care!
NSCAAgent.dll
; LUA script module used to write your own "check deamon" (sort of) early
beta.
LUAScript.dll
; Script to check external scripts and/or internal aliases, early beta.
CheckExternalScripts.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous!
NRPEClient.dll
Note: allowed_host is located under [Settings], [NSClient] and [NRPE] section. Make sure to
change allowed_host under [Settings] for this purpose.
(3) Modify NSC.ini and uncomment port. Edit the C:\Program Files\NSClient++\NSC.ini file
and uncomment the port# under [NSClient] section
(4) Modify NSC.ini and specify password. You can also specify a password the nagios server
needs to use to remotely access the NSClient++ agent.
[Settings]
;# OBFUSCATED PASSWORD
; This is the same as the password option but here you can store the
password in an obfuscated manner.
; *NOTICE* obfuscation is *NOT* the same as encryption, someone with access
to this file can still figure out the
; password. Its just a bit harder to do it at first glance.
;obfuscated_password=Jw0KAUUdXlAAUwASDAAB
;
;# PASSWORD
; This is the password (-s) that is required to access NSClient remotely. If
you leave this blank everyone will be able to access the daemon remotly.
password=My2Secure$Password
Start the NSClient++ service either from the Control Panel -> Administrative tools -> Services -
> Select “NSClientpp (Nagios) 0.3.1.14 2008-03-12 w32″ and click on start (or) Click on “Start -
> All Programs -> NSClient++ -> Start NSClient++ (Win32) . Please note that this will start the
NSClient++ as a windows service.
Later if you modify anything in the NSC.ini file, you should restart the “NSClientpp (Nagios)
0.3.1.14 2008-03-12 w32″ from the windows service.
3. Modify /usr/local/nagios/etc/objects/windows.cfg
By default a sample host definition for a windows server is given under windows.cfg, modify
this to reflect the appropriate windows server that needs to be monitored through nagios.
define host{
use windows-server ; Inherit default values from a
template
host_name remote-windows-host ; The name we're giving to this host
alias Remote Windows Host ; A longer name associated with the
host
address 192.168.1.4 ; IP address of the remote
windows host
}
Following are the default windows services that are already enabled in the sample windows.cfg.
Make sure to update the host_name on these services to reflect the host_name defined in the
above step.
define service{
use generic-service
host_name remote-windows-host
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
define service{
use generic-service
host_name remote-windows-host
service_description Uptime
check_command check_nt!UPTIME
}
define service{
use generic-service
host_name remote-windows-host
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
define service{
use generic-service
host_name remote-windows-host
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
define service{
use generic-service
host_name remote-windows-host
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service
host_name remote-windows-host
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
define service{
use generic-service
host_name remote-windows-host
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
If you specified a password in the NSC.ini file of the NSClient++ configuration file on the
Windows machine, you’ll need to modify the check_nt command definition to include the
password. Modify the /usr/local/nagios/etc/commands.cfg file and add password as shown
below.
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s
My2Secure$Password -v $ARG1$ $ARG2$
}
[nagios-server]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight
check
INSTALLATION OF NAGIOSGRAPH
Install Pre-Requisites
PERL modules
Carp: 1.04
CGI: 3.55
Data::Dumper: 2.131
File::Basename: 2.74
File::Find: 1.10
MIME::Base64: 3.07
POSIX: 1.09
RRDs: 1.4004
Time::HiRes: 1.9724
optional
GD: 2.45
yum install perl-rrdtool perl-GD
cpan[2]> install GD
cpan[3]> exit
- Edit the perl scripts in the cgi and lib directories, modifying the
"use lib" line to point to the directory from the previous step.
vi /tmp/nagiosgraph-1.4.4/cgi/*.cgi /tmp/nagiosgraph-1.4.4/lib/insert.pl
(edit all file where use lib)
- Copy CSS and JavaScript files to a directory served by the web server:
cp /tmp/nagiosgraph-1.4.4/share/nagiosgraph.css /usr/local/nagios/share
cp /tmp/nagiosgraph-1.4.4/share/nagiosgraph.js /usr/local/nagios/share
- Edit /etc/nagiosgraph/nagiosgraph.conf. Set at least the following:
logfile = /var/log/nagiosgraph.log
cgilogfile = /var/log/nagiosgraph-cgi.log
perflog = /var/nagios/perfdata.log
rrddir = /var/nagios/rrd
mapfile = /etc/nagiosgraph/map
nagiosgraphcgiurl = /nagios/cgi-bin
javascript = /nagios/nagiosgraph.js
stylesheet = /nagios/nagiosgraph.css
- Set permissions of "logfile" so that the *nagios* user can write to it:
touch /var/log/nagiosgraph.log
chown nagios.nagcmd /var/log/nagiosgraph.log
chmod 644 /var/log/nagiosgraph.log
- Set permissions of "cgilogfile" so that the *www* user can write to it:
touch /var/log/nagiosgraph-cgi.log
chown nagios.apache /var/log/nagiosgraph-cgi.log
chmod 644 /var/log/nagiosgraph-cgi.log
- Ensure that the *nagios* user can create and delete perfdata files:
chown nagios.nagcmd /var/nagios
chmod 755 /var/nagios
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$|
|$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata
- In the Nagios commands file (commands.cfg) add this:
define command {
command_name process-service-perfdata
command_line /usr/local/nagios/libexec/insert.pl
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- Restart nagios
/etc/init.d/nagios restart
http://server/nagios/cgi-bin/showconfig.cgi
http://server/nagios/cgi-bin/show.cgi
define service {
name graphed-service
action_url /nagiosgraph/cgi-
bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$'
onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()'
rel='/nagiosgraph/cgi-
bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-
w+450+-j
register 0
}
define service {
use local-service,graphed-service
...
}
- Replace the Nagios action icon with the nagiosgraph graph icon:
mv /usr/local/nagios/share/images/action.gif
/usr/local/nagios/share/images/action.gif-orig
cp share/graph.gif /usr/local/nagios/share/images/action.gif
<ul>
<li><a href="/nagios/cgi-bin/show.cgi" target="main">Graphs</a></li>
<li><a href="/nagios/cgi-bin/showhost.cgi" target="main">Graphs by
Host</a></li>
<li><a href="/nagios/cgi-bin/showservice.cgi" target="main">Graphs by
Service</a></li>
<li><a href="/nagios/cgi-bin/showgroup.cgi" target="main">Graphs by
Group</a></li>
</ul>
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- Restart nagios
/etc/init.d/nagios restart