I First step :
Let me show you how to install nagios monitoring tool .
This installation has been tested by unixmen team in Fedora/Cenots/RHEL/ .
1- First install some tools : httpd, gcc, glib, glibc-common, gd and gd-devel
yum install httpd php
yum install gcc
yum install glibc glibc-common
yum install gd gd-devel
2- Create nagios user :
#/usr/sbin/useradd -m nagios
#passwd nagios
3- Add nagcmd group
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
4- Now go to http://www.nagios.org download files .
nagios-3.1.0.tar.gz nagios-plugins-1.4.13.tar.gz nrpe-2.12.tar.gz
These commands will download version 3.2.0 of the Core Nagios files and version 1.4.13 of the Nagios plugins.
From command line:
-> wget http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.2.0/nagios-3.2.0.tar.gz?use_mirror=softlayer
-> wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.13/nagios-plugins-1.4.13.tar.gz?use_mirror=softlayer
> tar -xzvf nagios-3.0.6.tar.gz
-> cd nagios-3.0.6
-> ./configure --with-command-group=nagcmd
-> make all
-> make install
-> make install-init
-> make install-config
-> make install-commandmode
From command line:
-> wget http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.2.0/nagios-3.2.0.tar.gz?use_mirror=softlayer
-> wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.13/nagios-plugins-1.4.13.tar.gz?use_mirror=softlayer
> tar -xzvf nagios-3.0.6.tar.gz
-> cd nagios-3.0.6
-> ./configure --with-command-group=nagcmd
-> make all
-> make install
-> make install-init
-> make install-config
-> make install-commandmode
make install-webconf
5- Edit your email admin address :
Go to
vi /usr/local/nagios/etc/objects/contacts.cfg
6- Create a nagiosadminaccount for logging into the Nagios web interfaceassign to this you’ll need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
enter the password.
7- Restart the httpd server :
#Service httpd restart
The second step : Extract and install plugins
1- Go to you downloaded nagios tools
tar -zxvf nagios-plugins-1.4.13.tar.gz
2- cd nagios-plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make; make install
3- Now you have to add nagios to Chkconfig
chkconfig --add nagios
chkconfig nagios on
4- Verify if you have a good config of nagios with the command
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
5- Check if there are no errors displayed; then start nagios with command :
service nagios start
To simplify the procesure please disable the selinux and iptables and ip6tables
N.B : Please if you have questions about debian or ubuntu or othe unix system . we are here to help.
if ou have more questions abouth commands nrpe ? , how to add new client to the server ?Feel free to ask Me.
**********************************************************************
I. Overview
II. 6 steps to install Nagios plugin and NRPE on remote host.
Download Nagios Plugins and NRPE Add-on
Create nagios account
Install Nagios Plugins
Install NRPE
Setup NRPE to run as daemon
Modify the /usr/local/nagios/etc/nrpe.cfg
III. 4 Configuration steps on the Nagios monitoring server to monitor remote host:
Download NRPE Add-on
Install check_nrpe
Create host and service definition for remote host
Restart the nagios service
I. Overview:
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.
Nagios will execute check_nrpe command on nagios-server and request it to monitor disk usage on remote host using check_disk command.
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.
The results of the check_disk command will be returned back by NRPE daemon to the check_nrpe on nagios-server.
Following flow summarizes the above explanation:
Nagios Server (check_nrpe) —–> Remote host (NRPE deamon) —–> check_disk
Nagios Server (check_nrpe) <—– Remote host (NRPE deamon) <—– check_disk (returns disk space usage)
II. 7 steps to install Nagios Plugins and NRPE on the remote host
.
1. Download Nagios Plugins and NRPE Add-on
Download following files from Nagios.org and move to /home/downloads:
nagios-plugins-1.4.11.tar.gz
nrpe-2.12.tar.gz
2. Create nagios account
[remotehost]# useradd nagios
[remotehost]# passwd nagios
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
[remotehost]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
[remotehost]# make
[remotehost]# make install
[remotehost]# chown nagios.nagios /usr/local/nagios
[remotehost]# chown -R nagios.nagios /usr/local/nagios/libexec/
Note: On Red Hat, For me the ./configure command was hanging with the the message: “checking for redhat spopen problem…”. Add --enable-redhat-pthread-workaround to the ./configure command as a work-around for the above problem.
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
5. Setup NRPE to run as daemon (i.e as part of 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)
only_from = 127.0.0.1 192.168.1.2
Modify the /etc/services and add the following at the end of the file.
nrpe 5666/tcp # NRPE
Start the service
[remotehost]#service xinetd restart
Verify whether NRPE is listening
[remotehost]# netstat -at | grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
Verify to make sure the NRPE is functioning properly
[remotehost]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
6. Modify the /usr/local/nagios/etc/nrpe.cfg
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:
[remotehost]#/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
DISK CRITICAL - free space: / 6420 MB (10% inode=98%);| /=55032MB;51792;58266;0;64741
In the above example, since the free disk space on /dev/hda1 is only 10% , it is displaying the CRITICAL message, which will be returned to nagios server.
III. 4 Configuration steps on the Nagios monitoring server to monitor remote host:
.
1. Download NRPE Add-on
Download nrpe-2.12.tar.gz from Nagios.org and move to /home/downloads:
2. Install check_nrpe on the nagios monitoring server
[nagios-server]# tar xvfz nrpe-2.12.tar.gz
[nagios-server]# cd nrpe-2.1.2
[nagios-server]# ./configure
[nagios-server]# make all
[nagios-server]# make install-plugin
./configure will give a configuration summary as shown below:
*** Configuration summary for nrpe 2.12 05-31-2008 ***:
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]# rpm -ivh openssl-devel-0.9.7a-43.16.i386.rpm krb5-devel-1.3.4-47.i386.rpm zlib-devel-1.2.1.2-1.2.i386.rpm e2fsprogs-devel-1.35-12.5.
el4.i386.rpm
warning: openssl-devel-0.9.7a-43.16.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing… ########################################### [100%]
1:e2fsprogs-devel ########################################### [ 25%]
2:krb5-devel ########################################### [ 50%]
3:zlib-devel ########################################### [ 75%]
4:openssl-devel ########################################### [100%]
Verify whether nagios monitoring server can talk to the remotehost.
[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.
3. Create host and service definition for remotehost
Create a new configuration file /usr/local/nagios/etc/objects/remotehost.cfg to define the host and service definition for this particular remotehost. It is good to take the localhost.cfg and copy it as remotehost.cfg and start modifying it according to your needs.
host definition sample:
define host{
use linux-server
host_name remotehost
alias Remote Host
address 192.168.1.3
contact_groups admins
}
Service definition sample:
define service{
use generic-service
service_description Root Partition
contact_groups admins
check_command check_nrpe!check_disk
}
Note: In all the above examples, replace remotehost with the corresponding hostname of your remotehost.
4. Restart the nagios service
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.
[nagios-server]# service nagios reload
*********************************************************************************
I First step :
Let me show you how to install nagios monitoring tool .
This installation has been tested by unixmen team in Fedora/Cenots/RHEL/ .
1- First install some tools : httpd, gcc, glib, glibc-common, gd and gd-devel
yum install httpd php
yum install gcc*
yum install glibc* glibc-common*
yum install gd gd-devel
2- Create nagios user :
#/usr/sbin/useradd -m nagios
#passwd nagios
3- Add nagcmd group
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
4- Now go to http://www.nagios.org download files .
nagios-3.1.0.tar.gz nagios-plugins-1.4.13.tar.gz nrpe-2.12.tar.gz
tar -zxvf nagios-3.1.0.tar.gz
cd nagios-3.1.0
./configure --with-command-group=nagcmd
#make all; make install; make install-init; make install-config; make install-commandmode; make install-webconf
5- Edit your email admin address :
Go to
vi /usr/local/nagios/etc/objects/contacts.cfg
6- Create a nagiosadmin account for logging into the Nagios web interfaceassign to this you’ll need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
enter the password.
7- Restart the httpd server :
#Service httpd restart
The second step : Extract and install plugins
1- Go to you downloaded nagios tools
tar -zxvf nagios-plugins-1.4.13.tar.gz
2- cd nagios-plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make; make install
3- Now you have to add nagios to Chkconfig
chkconfig --add nagios
chkconfig nagios on
4- Verify if you have a good config of nagios with the command
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
5- Check if there are no errors displayed; then start nagios with command :
service nagios start
To simplify the procesure please disable the selinux and iptables and ip6tables
now open your browser and http://localhost/nagios orr http://ip/nagios
-----------------------------------------------------------------------------------------------
NSCLIENT++
[modules]
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll
CheckNSCP.dll
;
CheckExternalScripts.dll
;
NSCAAgent.dll
;
LUAScript.dll
;
;RemoteConfiguration.dll
;NRPEClient.dll
CheckTaskSched.dll
[crash]
; Archive crash dump files if a crash is detected
;archive=1
; Submit crash reports to a crash report server (this overrrides archive)
;submit=0
; Restart service if a crash is detected
restart=1
[Settings]
;obfuscated_password=Jw
;
;# PASSWORD
;password=secret-password
;
;# ALLOWED HOST ADDRESSES
;allowed_hosts=127.0.0.1/32
;
;# USE THIS FILE
use_file=1
allowed_hosts=77.170.218.63
;
; # USE SHARED MEMORY CHANNELS
shared_session=1
[log]
;# LOG DEBUG
debug=1
;
;# LOG FILE
file=nsclient.log
;
;# LOG DATE MASK
date_mask=%Y-%m-%d %H:%M:%S
;
;# LOG ROOT FOLDER
root_folder=exe
[NSClient]
;# ALLOWED HOST ADDRESSES
;allowed_hosts=
;
;# NSCLIENT PORT NUMBER
port=12489
;
;# BIND TO ADDRESS
;bind_to_address=
;
;# SOCKET TIMEOUT
;socket_timeout=30
[NRPE]
;# NRPE PORT NUMBER
;port=5666
;
;# COMMAND TIMEOUT
;command_timeout=60
;
;# COMMAND ARGUMENT PROCESSING
;allow_arguments=0
;
;# COMMAND ALLOW NASTY META CHARS
;allow_nasty_meta_chars=0
;
;# USE SSL SOCKET
;use_ssl=1
;
;# BIND TO ADDRESS
; bind_to_address=
;
;# ALLOWED HOST ADDRESSES
;allowed_hosts=
;
;# SCRIPT DIRECTORY
;script_dir=scripts\
;
;# SOCKET TIMEOUT
;socket_timeout=30
[Check System]
;# CPU BUFFER SIZE
;CPUBufferSize=1h
;
;# CHECK RESOLUTION
;CheckResolution=10
;
;# CHECK ALL SERVICES
; Configure how to check services when a CheckAll is performed.
; ...=started means services in that class *has* to be running.
; ...=stopped means services in that class has to be stopped.
; ...=ignored means services in this class will be ignored.
;check_all_services[SERVICE_BOOT_START]=ignored
;check_all_services[SERVICE_SYSTEM_START]=ignored
;check_all_services[SERVICE_AUTO_START]=started
;check_all_services[SERVICE_DEMAND_START]=ignored
;check_all_services[SERVICE_DISABLED]=stopped
[External Script]
;# COMMAND TIMEOUT
;command_timeout=60
;
;# COMMAND ARGUMENT PROCESSING
;allow_arguments=0
;
;# COMMAND ALLOW NASTY META CHARS
;allow_nasty_meta_chars=0
;
;# SCRIPT DIRECTORY
;script_dir=c:\my\script\dir
[Script Wrappings]
vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%
ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
bat=scripts\%SCRIPT% %ARGS%
[External Scripts]
;check_es_long=scripts\long.bat
;check_es_ok=scripts\ok.bat
;check_es_nok=scripts\nok.bat
;check_vbs_sample=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs
;check_powershell_warn=cmd /c echo scripts\powershell.ps1 | powershell.exe -command -
[External Alias]
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s
alias_cpu_ex=checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page
alias_up=checkUpTime MinWarn=1d MinWarn=1h
alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
alias_disk_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable
alias_volumes=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED
alias_volumes_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable
alias_service=checkServiceState CheckAll
alias_service_ex=checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc
alias_process=checkProcState "$ARG1$=started"
alias_process_stopped=checkProcState "$ARG1$=stopped"
alias_process_count=checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started"
alias_process_hung=checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung"
alias_event_log=CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"
alias_file_size=CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" max-dir-depth=10
alias_file_age=checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%"
alias_sched_all=CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0
alias_sched_long=CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0
alias_sched_task=CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0
alias_updates=check_updates -warning 0 -critical 0
check_ok=CheckOK Everything is fine!
[Wrapped Scripts]
;check_test_vbs=check_test.vbs /arg1:1 /arg2:1 /variable:1
;check_test_ps1=check_test.ps1 arg1 arg2
;check_test_bat=check_test.bat arg1 arg2
;check_battery=check_battery.vbs
;check_printer=check_printer.vbs
;check_updates=check_updates.vbs
; [includes]
;
; myotherfile.ini
; real.ini
[NSCA Agent]
;# CHECK INTERVALL (in seconds)
;interval=5
;
;# ENCRYPTION METHOD
;
; Note: The encryption method you specify here must match the decryption method the nsca daemon uses
; (as specified in the nsca.cfg file)!!
; Values:
; 0 = None (Do NOT use this option)
; 1 = Simple XOR (No security, just obfuscation, but very fast)
; 2 = DES
; 3 = 3DES (Triple DES)
; 4 = CAST-128
; 6 = xTEA
; 8 = BLOWFISH
; 9 = TWOFISH
; 11 = RC2
; 14 = RIJNDAEL-128 (AES)
; 20 = SERPENT
;encryption_method=14
;
;# ENCRYPTION PASSWORD
;password=
;
;# BIND TO ADDRESS
; -- not supported as of now --
;bind_to_address=
;
;# LOCAL HOST NAME
;hostname=
;
;# NAGIOS SERVER ADDRESS
;nsca_host=192.168.0.1
;
;# NAGIOS SERVER PORT
;nsca_port=5667
;
;# CHECK COMMAND LIST
;
[NSCA Commands]
;my_cpu_check=checkCPU warn=80 crit=90 time=20m time=10s time=4
;my_mem_check=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=page
;my_svc_check=checkServiceState CheckAll exclude=wampmysqld exclude=MpfService
;host_check=check_ok
;# REMOTE NRPE PROXY COMMANDS
; A list of commands that check other hosts.
; Used by the NRPECLient module
[NRPE Client Handlers]
check_other=-H 192.168.0.1 -p 5666 -c remote_command -a arguments
;# LUA SCRIPT SECTION
; A list of all Lua scripts to load.
;[LUA Scripts]
;scripts\test.lua