Vous êtes sur la page 1sur 34

23/11/2016 HowtoInstallNagios4.2.

0onRedHat,CentOSorFedoraLinux

Home About Sitemap Searchhere...

How to Disable Those How to Install Windows 10 on


Annoying Ads From Windows a Chromebook
10

How to Deploy the vCenter 6.5 Protect Your Server Against the
Server Appliance Dirty COW Linux Vulnerability

How to Install Nagios 4.2.0 on


Red Hat, CentOS or Fedora Linux
POPULAR

How to Install
Nagios 4.2.0 on Red
Hat, CentOS or
Fedora Linux

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 1/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

How to Sort Excel


Worksheet Tabs in
Alphabetical Order

How to Remove
Docker Images,
Containers, and
Volumes

How to Set Up and


Use Multiple
Desktops on
Nagios is an amazing Open Source monitoring tool which provides Windows 10 PC
you pretty much comprehensive monitoring environment to
always keep an eye on your all Workstations, Servers and Network How to Move
devices whether you want to monitor a data center or just a small Photos From
business server room. iPhone or iPad to
Windows 10 PC

How to Install
Asterisk 11 and
Dhadi on RHEL,
Using Nagios, you can monitor network enabled devices and their CentOS, Fedora or Ubuntu
services remotely on a single window. It shows warnings and Linux
alerts if something goes wrong within on premises datacenter or
DR Site which eventually helps us to predict failure before they vCenter Server
occur. It also help us to reduce downtime during peak business Appliance 6.5 New
hours. Features

Recently, Nagios released its latest versions of Nagios 4.2.0 and its How to Determine
latest stable release of Nagios plugins 2.1.2 on August 01, 2016. the Presence of
Bad Sectors on a
This Nagios Guide with step by step instructions on how to install Disk Drive in Linux
latest Nagios 4.2.0 from source (tarball) on RHEL 7.x/6.x/5.x,
CentOS 7.x/6.x/5.x and Fedora 24-19 distributions. How to Set Up an
Android Device as
The below steps was performed on CentOS 7.2 Linux distribution a Second Display
during the time when this particular article was being written. Screen for Your Windows PC
or Mac

How to Install Nagios 4.2.0 and


How to Protect
Nagios Plugin 2.1.2 TeamViewer for
More Secure
If you follow below mentioned guideline correctly, you will
Remote Access
end up with following information.

1 Nagios and its plugins will be installed under


/usr/local/nagios directory.
http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 2/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

2 Nagios will be congured to monitor few services of your


ALL POSTS
local machine (Disk Usage, CPU Load, Current Users,
Total Processes, etc.)
2016 (171)
3 Nagios web interface will be available at
November (17)
http://localhost/nagios
How to Sort Excel
Worksheet Tabs in
Alphabetical O...
How to Remove Docker
Install Required Dependencies Images, Containers, and
Volum...
You need to install prerequisites Apache, PHP and some How to Set Up and Use
Multiple Desktops on
libraries like gcc, glibc, glibc-common and GD libraries and
Windows...
its development libraries before installing Nagios 4.2.0 using
How to Move Photos
source. To install these packages, you can use yum default From iPhone or iPad to
package installer. Windows ...
How to Install Asterisk 11
yuminstallyhttpdphpgccglibcglibccommongd and Dhadi on RHEL,
Cent...
gddevelmakenetsnmp
How to Set Up an Android
Device as a Second
Displa...
Google Cloud Platform
Introduction
How to Clear Live Tile
Notications During
Shutdo...
How to Add and Monitor
Network Switch, Router
Usin...
IfyouareonFedorathenusethefollowingcommand.
How to Install Nagios 4.2.0
on Red Hat, CentOS or
...
How to Determine the
Presence of Bad Sectors
dnfinstallyhttpdphpgccglibcglibccommongd on a ...
How to Install and
gddevelmakenetsnmp
congure PowerShell
for Azure ...
How to reset forgotten
Active Directory
Create Nagios User and Group administra...
How to Change the
Create a new nagios user and nagcmd group account and Default Quiet Hours on
set a password. Your Wind...
How to Automatically Fill
Sequential Data into
Exc...
useraddnagios
How to Properly Remove
groupaddnagcmd "Windows.old" Folder
on Win...
How to Install Vagrant
Free Tool to Automate
http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 3/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Now add both the nagios user and the apache user to the VM Pr...
nagcmd group. October (12)
September (17)
August (17)
July (3)
usermodGnagcmdnagios
usermodGnagcmdapache June (7)
May (15)
April (60)
March (20)
February (3)
Download Nagios Core 4.2.0 and 2015 (2)
2014 (7)
Nagios Plugin 2.1.2 2008 (1)

Create a directory for your Nagios installation and all its


future downloads.

mkdir/root/nagios
cd/root/nagios

Now download latest Nagios Core 4.2.0 and Nagios plugins


2.1.2 packages with wget command.

wget
http://prdownloads.sourceforge.net/sourceforge/nag
ios/nagios4.2.0.tar.gz

wgethttps://www.nagios
plugins.org/download/nagiosplugins2.1.2.tar.gz


Extract Nagios Core and its
Plugins
We need to extract downloaded package with tar command
as follows.

tarxvfnagios4.2.0.tar.gz
tarxvfnagiosplugins2.1.2.tar.gz

When you extract these tarballs with tar command, two new

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 4/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

folders will appear in that directory.

lsl
total13528
drwxrwxrx.18rootroot4096Aug202015 nagios4.2.0
rwrr.1rootroot11142182Aug202015nagios4.2.0.tar.gz
drwxrxrx.15rootroot4096Aug121:58 nagiosplugins2.1.2
rwrr.1rootroot2695301Aug121:58nagiosplugins2.1.2.tar.gz


Congure Nagios Core
First we will congure Nagios Core. We need to go to Nagios
directory and run congure command with required prex as
show below.

nagios~]#cdnagios4.2.0
nagios4.2.0]#./configurewithcommandgroup=nagcmd

Sample output:

Creatingsampleconfigfilesinsampleconfig/...
***Configurationsummaryfornagios4.2.008012016***:
GeneralOptions:

Nagiosexecutable:nagios
Nagiosuser/group:nagios,nagios
Commanduser/group:nagios,nagcmd
EventBroker:yes
Install${prefix}:/usr/local/nagios
Install${includedir}:/usr/local/nagios/include/nagios
Lockfile:${prefix}/var/nagios.lock
Checkresultdirectory:${prefix}/var/spool/checkresults
Initdirectory:/etc/rc.d/init.d
Apacheconf.ddirectory:/etc/httpd/conf.d
Mailprogram:/bin/mail
HostOS:linuxgnu
IOBrokerMethod:epoll
WebInterfaceOptions:

HTMLURL:http://localhost/nagios/
CGIURL:http://localhost/nagios/cgibin/
Traceroute(usedbyWAP):/usr/bin/traceroute

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 5/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Reviewtheoptionsaboveforaccuracy.Iftheylookokay,
type'makeall'tocompilethemainprogramandCGIs.

Now, after conguring 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.

makeall
makeinstall

Sample output:

***Exfoliationthemeinstalled***
NOTE:Use'makeinstallclassicui'torevertto
classicNagiostheme
make[1]:Leavingdirectory'/root/nagios/nagios
4.2.0'
makeinstallbasic
make[1]:Enteringdirectory'/root/nagios/nagios
4.2.0'
/usr/bin/installcm775onagiosgnagiosd
/usr/local/nagios/libexec
/usr/bin/installcm775onagiosgnagiosd
/usr/local/nagios/var
/usr/bin/installcm775onagiosgnagiosd
/usr/local/nagios/var/archives
/usr/bin/installcm775onagiosgnagcmdd
/usr/local/nagios/var/spool/checkresults
chmodg+s/usr/local/nagios/var/spool/checkresults
***Mainprogram,CGIsandHTMLfilesinstalled
***
YoucancontinuewithinstallingNagiosasfollows
(type'make'
withoutanyargumentsforalistofallpossible
options):
makeinstallinit
Thisinstallstheinitscriptin
/etc/rc.d/init.d
makeinstallcommandmode
Thisinstallsandconfigurespermissionsonthe

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 6/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

directoryforholdingtheexternalcommandfile
makeinstallconfig
Thisinstallssampleconfigfilesin
/usr/local/nagios/etc
make[1]:Leavingdirectory'/root/nagios/nagios
4.2.0'

Following command will install the init scripts for Nagios.

makeinstallinit

To make nagios work from command line we need to install


command-mode.

makeinstallcommandmode

Next, install sample nagios les, please run following


command.

makeinstallconfig

Sample output:

/usr/bin/installcm775onagiosgnagiosd
/usr/local/nagios/etc
/usr/bin/installcm775onagiosgnagiosd
/usr/local/nagios/etc/objects
/usr/bin/installcbm664onagiosgnagios
sampleconfig/nagios.cfg
/usr/local/nagios/etc/nagios.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/cgi.cfg
/usr/local/nagios/etc/cgi.cfg
/usr/bin/installcbm660onagiosgnagios
sampleconfig/resource.cfg
/usr/local/nagios/etc/resource.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/templateobject/templates.cfg
/usr/local/nagios/etc/objects/templates.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/templateobject/commands.cfg
/usr/local/nagios/etc/objects/commands.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/templateobject/contacts.cfg
/usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/installcbm664onagiosgnagios
http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 7/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

sampleconfig/templateobject/timeperiods.cfg
/usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/templateobject/localhost.cfg
/usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/templateobject/windows.cfg
/usr/local/nagios/etc/objects/windows.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/templateobject/printer.cfg
/usr/local/nagios/etc/objects/printer.cfg
/usr/bin/installcbm664onagiosgnagios
sampleconfig/templateobject/switch.cfg
/usr/local/nagios/etc/objects/switch.cfg
***Configfilesinstalled***
Remember,theseare*SAMPLE*configfiles.You'll
needtoread
thedocumentationformoreinformationonhowto
actuallydefine
services,hosts,etc.tofityourparticular
needs.


Customizing Nagios
Conguration
Open the contacts.cfg le with your choice of editor and
set the email address associated with the nagiosadmin
contact denition to receiving email alerts.

#vi/usr/local/nagios/etc/objects/contacts.cfg

Sample Output

##################################################
#############################
##################################################
###############################CONTACTS#
##################################################
#############################
##################################################

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 8/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

##############################Justonecontact
definedbydefaulttheNagiosadmin(that'syou)
#Thiscontactdefinitioninheritsalotof
defaultvaluesfromthe'genericcontact'#
templatewhichisdefinedelsewhere.define
contact{contact_name
nagiosadminShortnameof
userusegenericcontactInheritdefaultvalues
fromgenericcontacttemplate(definedabove)
aliasNagiosAdminFullnameofuseremail
support@infosbird.com
***CHANGETHISTOYOUR
EMAILADDRESS****}


Install and Congure Web
Interface for Nagios
We are done with all conguration in the backend, now we
will congure Web Interface For Nagios with following
command. The below command will Congure Web interface
for Nagios and a web admin user will be created
nagiosadmin.

makeinstallwebconf

In this step, we will be creating a password for nagiosadmin.


After executing this command, please provide a password
twice and keep it remember because this password will be
used when you login in the Nagios Web interface.

htpasswdsc
/usr/local/nagios/etc/htpasswd.usersnagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Restart Apache to make the new settings take eect.

service httpd start [On RHEL/CentOS 6/5 and


Fedora]
systemctl start httpd.service [On RHEL/CentOS 7 and
Fedora 19 Onwards]

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 9/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Compile and Install Nagios


Plugin
We have downloaded nagios plugins in /root/nagios, Go
there and congure and install it as directed below.

cd/root/nagios
cdnagiosplugins2.1.2/
./configurewithnagiosuser=nagioswith
nagiosgroup=nagios
make
makeinstall


Verify Nagios Conguration
Files
Now we are all done with Nagios conguration and its time
to verify it and to do so please insert following command. If
everything goes smooth it will show up similar to below
output.

/usr/local/nagios/bin/nagiosv/usr/local/nagios/etc/nagios.cfg

Sample Output

NagiosCore4.2.0
Copyright(c)2009presentNagiosCoreDevelopment
TeamandCommunityContributors
Copyright(c)19992009EthanGalstad
LastModified:08012016
License:GPL
Website:https://www.nagios.org
Readingconfigurationdata...
Readmainconfigfileokay...
Readobjectconfigfilesokay...
Runningpreflightcheckonconfigurationdata...
Checkingobjects...
Checked8services.
Checked1hosts.
Checked1hostgroups.

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 10/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Checked0servicegroups.
Checked1contacts.
Checked1contactgroups.
Checked24commands.
Checked5timeperiods.
Checked0hostescalations.
Checked0serviceescalations.
Checkingforcircularpaths...
Checked1hosts
Checked0servicedependencies
Checked0hostdependencies
Checked5timeperiods
Checkingglobaleventhandlers...
Checking obsessive compulsive processor
commands...
Checkingmiscsettings...
TotalWarnings:0
TotalErrors:0
Things look okay No serious problems were
detectedduringthepreflightcheck


Add Nagios Services to System
Startup
To make Nagios work across reboots, we need to add nagios
and httpd with chkcong and systemctl command.


On RHEL/CentOS 6/5 and Fedora

chkconfigaddnagios
chkconfiglevel35nagioson
chkconfigaddhttpd
chkconfiglevel35httpdon

On RHEL/CentOS 7 and Fedora 19-24

systemctlenablenagios
systemctlenablehttpd

Restart Nagios to make the new settings take eect.


http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 11/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

servicenagiosstart [OnRHEL/CentOS6/5andFedora
systemctlstartnagios.service [OnRHEL/CentOS7andFedora1924


Login to the Nagios Web
Interface
Your nagios is ready to work, please open it in your browser
with http://server-ip-address/nagios or
http://hostname/nagios and Provide the username
nagiosadmin and password.

Nagios Web Dashboard

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 12/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Nagios Host View

Nagios Monitoring Overview

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 13/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Service View

Process View

Here we have successfully installed and congured Nagios


and its Plugins and its ready to monitor your network
enabled devices.


Upgrade Nagios 3.x to Nagios
4.2.0

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 14/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

If you are already running an older version of Nagios, you


can upgrade it anytime. To start upgrade process, you just
need to download the latest tar archive of Nagios and
congure it through the following commands.

servicenagiosstop
wget
http://prdownloads.sourceforge.net/sourceforge/nag
ios/nagios4.2.0.tar.gz
tarzxvfnagios4.2.0.tar.gz
cdnagios4.2.0
./configure
makeall
makeinstall
servicenagiosstart


Conclusion
We have completed Nagios installation and conguration
process. Now I'll walk you through the steps to add Linux,
Windows, Printers, Switches, Routers, Firewalls and other
network enabled Devices to your Nagios monitoring Server.

How to Add Linux Host to Nagios


Monitoring Server Using NRPE
Plugin

Nagios Remote Plugin Executor (NRPE ) allows you to monitor


any remote Linux/Unix services or network devices. The
NRPE add-on allows Nagios to monitor any local resources
like CPU load, Swap, Memory usage, Online users, etc. on
remote Linux machines. These local resources are not mostly
exposed to external machines, so that NRPE agent must be
installed and congured on the remote machines.

Note: The NRPE addon requires that Nagios Plugins must be


installed on the remote Linux machine. Without these, the
NRPE daemon will not work and will not monitor anything.


Installation of NRPE Plugin

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 15/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

To use the NRPE, you will need to do some additional tasks


on both the Nagios Monitoring Host and Remote Linux
Host that the NRPE installed on. I will be covering the both
installation parts separately.

I assume that you are installing the NRPE on a host that


supports TCP wrappers and Xinted daemon installed on it.
Most of the modern Linux distributions have these two
installed by default. If not, we will install it later during the
installation when required.

On a Remote Linux Host


Please use the following instructions to install Nagios Plugins
and NRPE daemon on the Remote Linux Host.


Install Required Dependencies
We need to install required libraries like gcc, glibc, glibc-
common and GD and its development libraries before
installing.

yuminstallygccglibcglibccommongdgddevel
makenetsnmpopenssldevel

IfyouareusingFedora22+orlaterversion
dnfinstallygccglibcglibccommongdgddevel
makenetsnmpopenssldevel


Create Nagios User
Create a new nagios user account and set a password.

useraddnagios
passwdnagios

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 16/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Install the Nagios Plugins


Create a directory for installation and all its future
downloads.

cd/root/nagios

Now download latest Nagios Plugins 2.1.2 package with wget


command.

wgethttps://www.nagios
plugins.org/download/nagiosplugins2.1.2.tar.gz


Extract Nagios Plugins
Run the following tar command to extract the source code
tarball. tar -xvf nagios-plugins-2.1.2.tar.gz After, extracting
one new folder will appear in that directory.

nagios~]#lsl
total2640
drwxrxrx.15 root root 4096 Aug 1 21:58
nagiosplugins2.1.2
rwrr. 1 root root 2695301 Aug 1 21:58
nagiosplugins2.1.2.tar.gz


Compile and Install Nagios
Plugins
Next, compile and install using following commands

cdnagiosplugins2.1.2
./configure
make
makeinstall

Set the permissions on the plugin directory.

chownnagios.nagios/usr/local/nagios
chownRnagios.nagios/usr/local/nagios/libexec

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 17/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux


Install Xinetd
Most of the systems, its by default installed. If not, install
xinetd package using following yum command.

yuminstallxinetd

If you are on Fedora 22+ or later

dnfinstallxinetd


Install NRPE Plugin
Download latest NRPE Plugin 3.0 packages with wget
command.

cd/root/nagios
wget
http://liquidtelecom.dl.sourceforge.net/project/na
gios/nrpe3.x/nrpe3.0.tar.gz
Unpack the NRPE source code tarball.

tar xzf nrpe-3.0.tar.gz


cd nrpe-3.0

Compile and install the NRPE addon.

./congure
make all

Next, install the NRPE plugin daemon, and sample daemon


cong le.

make install-plugin
make install-daemon
make install-daemon-cong

Install the NRPE daemon under xinetd as a service.

make install-xinetd
OR

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 18/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

make install-inetd

Now open /etc/xinetd.d/nrpe le and add the localhost and IP


address of the Nagios Monitoring Server.

only_from = 127.0.0.1 localhost <nagios_ip_address>

Next, open /etc/services le add the following entry for the


NRPE daemon at the bottom of the le.

nrpe 5666/tcp NRPE

Restart the xinetd service.

service xinetd restart


Verify NRPE Daemon Locally
Run the following command to verify the NRPE daemon
working correctly under xinetd.

netstat -at | grep nrpe


tcp 0 0 *:nrpe *:* LISTEN

If you get output similar to above, means it working correctly.


If not, make sure to check the following things.

Check youve added nrpe entry correctly in /etc/services le


The only_from contains an entry for nagios_ip_address in
the /etc/xinetd.d/nrpe le.
The xinetd is installed and started.
Check for the errors in the system log les for about xinetd
or nrpe and x those problems.

Next, verify the NRPE daemon is functioning properly. Run


the check_nrpe command that was installed earlier for
testing purposes.

/usr/local/nagios/libexec/check_nrpe -H localhost

You will get a following string on the screen, it shows you


what version of NRPE is installed:

NRPE v3.0


http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 19/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Congure Firewall Rules


Make sure that the Firewall on the local machine will allow
the NRPE daemon to be accessed from remote servers. To do
this, run the following iptables command.

On RHEL/CentOS 6/5 and Fedora


iptables -A INPUT -p tcp -m tcp --dport 5666 -j ACCEPT

On RHEL/CentOS 7 and Fedora 19 or later


rewall-cmd --permanent --zone=public --add-port=5666/tcp

Run the following command to Save the new iptables rule so


it will survive at system reboots.

On RHEL/CentOS 6/5 and Fedora


service iptables save


Customize NRPE commands
The default NRPE conguration le that got installed has
several command denitions that will be used to monitor this
machine. The sample conguration le located at.

vi /usr/local/nagios/etc/nrpe.cfg

The following are the default command denitions that are


located at the bottom of the conguration le. For the time
being, we assume you are using these commands. You can
check them by using the following commands.

# /usr/local/nagios/libexec/check_nrpe -H localhost -c
check_users
USERS OK - 1 users currently logged in |users=1;5;10;0

# /usr/local/nagios/libexec/check_nrpe -H localhost -c
check_load
OK - load average: 3.90, 4.37,
3.94|load1=3.900;15.000;30.000;0;
load5=4.370;10.000;25.000;0; load15=3.940;5.000;20.000;0;

# /usr/local/nagios/libexec/check_nrpe -H localhost -c
check_hda1
DISK OK - free space: /boot 154 MB (84% inode=99%);|

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 20/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

/boot=29MB;154;173;0;193

# /usr/local/nagios/libexec/check_nrpe -H localhost -c
check_total_procs
PROCS CRITICAL: 297 processes

# /usr/local/nagios/libexec/check_nrpe -H localhost -c
check_zombie_procs
PROCS OK: 0 processes with STATE = Z

You can edit and add new command denitions by editing the
NRPE cong le. Finally, youve successfully installed and
congured NRPE agent on the Remote Linux Host. Now its
time to install a NRPE component and add some services on
your Nagios Monitoring Server.

On Nagios Monitoring Server

Now login into your Nagios Monitoring Server. Here you will
need to do following things:

Install the check_nrpe plugin.


Create a Nagios command denition using the check_nrpe
plugin.
Create Nagios host and add service denitions for
monitoring the remote Linux host.


Install NRPE Plugin
Go to the nagios download directory and download latest
NRPE Plugin with wget command.

cd /root/nagios
wget
http://liquidtelecom.dl.sourceforge.net/project/nagios/nrpe-
3.x/nrpe-3.0.tar.gz

Unpack the NRPE source code tarball.

tar xzf nrpe-3.0.tar.gz


cd nrpe-3.0

Compile and install the NRPE addon.

./congure

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 21/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

make all
make install-daemon


Verify NRPE Daemon Remotely
Make sure that the check_nrpe plugin can communicate with
the NRPE daemon on the remote Linux host. Add the IP
address in the command below with the IP address of your
Remote Linux host.

/usr/local/nagios/libexec/check_nrpe -H
<remote_linux_ip_address>

You will get a string back that shows you what version of
NRPE is installed on the remote host, like this:

NRPE v3.0

If your receive a plugin time-out error, then check the


following things.
Make sure your rewall isnt blocking the communication
between the remote host and the monitoring host.
Make sure that the NRPE daemon is installed correctly
under xinetd.
Make sure that the remote Linux host rewall rules
blocking the monitoring server from communicating to the
NRPE daemon.

Adding Remote Linux Host to Nagios Monitoring Server

To add a remote host you need to create a two new les


hosts.cfg and services.cfg under /usr/local/nagios/etc/
location.

cd /usr/local/nagios/etc/
touch hosts.cfg
touch services.cfg

Now add these two les to main Nagios conguration le.


Open nagios.cfg le with any editor.

vi /usr/local/nagios/etc/nagios.cfg

Now add the two newly created les as shown below.

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 22/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

# You can specify individual object cong les as shown


below:
cfg_le=/usr/local/nagios/etc/hosts.cfg
cfg_le=/usr/local/nagios/etc/services.cfg

Now open hosts.cfg le and add the default host template


name and dene remote hosts as shown below. Make sure to
replace host_name, alias and address with your remote host
server details.

vi /usr/local/nagios/etc/hosts.cfg

## Default Linux Host Template ##


dene host{
name linux-box ; Name of this
template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notication_period 24x7
notication_interval 30
notication_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS -
ITS A TEMPLATE
}
## Default
dene host{
use linux-box ; Inherit default values
from a template
host_name tecmint ; The name we're
giving to this server
alias CentOS 6 ; A longer name for the
server
address 5.175.142.66 ; IP address of
Remote Linux host
}

Next open services.cfg le add the following services to be


monitored.

vi /usr/local/nagios/etc/services.cfg

dene service{

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 23/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

use generic-service
host_name tecmint
service_description CPU Load
check_command check_nrpe!check_load
}
dene service{
use generic-service
host_name tecmint
service_description Total Processes
check_command check_nrpe!check_total_procs
}
dene service{
use generic-service
host_name tecmint
service_description Current Users
check_command check_nrpe!check_users
}
dene service{
use generic-service
host_name tecmint
service_description SSH Monitoring
check_command check_nrpe!check_ssh
}
dene service{
use generic-service
host_name tecmint
service_description FTP Monitoring
check_command check_nrpe!check_ftp
}

Now NRPE command denition needs to be created in


commands.cfg le.

vi /usr/local/nagios/etc/objects/commands.cfg

Add the following NRPE command denition at the bottom of


the le.

##################################################
#######
#NRPECHECKCOMMAND
#
#CommandtouseNRPEtocheckremotehostsystems
##################################################
########
definecommand{
command_namecheck_nrpe
http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 24/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

command_line$USER1$/check_nrpeH$HOSTADDRESS$
c$ARG1$
}

Finally, verify Nagios Conguration les for any errors.

/usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0

Restart Nagios:

service nagios restart

Now go to Nagios Monitoring Web interface at http://server-


ip-address/nagios or http://hostname/nagios and Provide
the username nagiosadmin and password. Check that the
Remote Linux Host was added and is being monitored.

Now, in the next step I'll be showing you how to add Windows
host to Nagios monitoring Server.

To add and monitor a Windows Machines you will have


follow the below mentioned guideline.

1 Install NSClient++ addon on the Windows Machine.

2 Congure Nagios Server for monitoring Windows


Machine.

3 Add new host and service denitions for Windows


machine monitoring.

4 Restart the Nagios Service.

To make this pretty simple and easier, a few steps of


conguration we have already done in the Nagios
http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 25/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

installation.

1 A check_nt command denition already added to the


command.cfg le. This denition command is used by
check_nt plugin to monitor Windows services.

2 A windows-server host template already created in the


templates.cfg le. This template allows you to add new
Windows host denitions

These two les command.cfg and templates.cfg les can


be found at /usr/local/nagios/etc/objects/ directory. You
can modify and add your own denitions that suits your
requirement.


Installing NSClient++ Agent on
Windows Machine
Lets install NSClient++ Agent on the Remote Windows
Host. First download the latest stable version NSClient++
0.3.1 addon source les, which can be obtained from
http://sourceforge.net/projects/nscplus/

Once youve downloaded latest stable version, unzip the


NSClient++ les into a new C:\NSClient++ directory.

Now open a MS-DOS command prompt from the Start


Screen > Run > type cmd and press enter and change to
the C:\NSClient++ directory.

C:\NSClient++

Next, register the NSClient++ service on the system with the


following command.

nsclient++/install

Finally, install the NSClient++ systray with the following


command.

nsclient++SysTray
http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 26/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Go to the Windows Services Manager and right click on


NSClient go to Properties and then Log On tab and click the
check box that says Allow service to interact with the
desktop. If it isnt already allowed, please check the box to
allow it to.

Open NSC.INI le located at C:\NSClient++ directory and


uncomment all the modules dened in the modules
section, except for CheckWMI.dll and
RemoteConguration.dll.

[modules]
#NSCLIENT++MODULES
#AlistwithDLLstoloadatstartup.
You will need to enable some of these for
NSClient++towork.
!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!

*
*
*NOTICE!!!YOUHAVETOE
DITTHIS*

*
*
!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!
FileLogger.dll
CheckSystem.dll
CheckDisk.dll

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 27/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
CheckWMI.dll

RemoteConfigur ation IS AN EXTREM EARLY IDEA SO
DONTUSEFORPRODUCTIONENVIROMNEMTS!
RemoteConfiguration.dll
NSCAAgentisanewbetamoduleusewithcare!
NSCAAgent.dll
LUA script module used to write your own "check
deamon"(sortof)earlybeta.
LUAScript.dll
Script tocheck external scriptsand/or internal
aliases,earlybeta.
CheckExternalScripts.dll
Check other hosts through NRPE extreme beta and
probablyabitdangerous!:)
Ho NRPEClient.dll
How Windo Lin Andro i iPho Ne Tech
me To ws ux id O ne ws Support
S
Uncomment the allowed_hosts in the Settings section
and dene the IP address of your Nagios Monitoring Server
or leave it blank to allow any hosts to connect.

[Settings]
#ALLOWEDHOSTADDRESSES
ThisisacommadelimitedlistofIPaddressof
hoststhatareallowedtotalktothealldaemons.
Ifleavethisblankanyonecanaccessthe
deamonremotly(NSClientstillrequiresavalid
password).
Thesyntaxishostorip/maskso192.168.0.0/24
willallowanyoneonthatsubnetaccess
allowed_hosts=172.16.27.41

Uncomment the port in the NSClient section and set to


default port 12489. Make sure to open 12489 port on
Windows Firewall.

[NSClient]
#NSCLIENTPORTNUMBER
This is the port the NSClientListener.dll will
listento.

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 28/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

port=12489

Finally start the NSClient++ service with the following


command.

nsclient++ /start

If your properly installed and congured, you should see a


new icon in the system tray in yellow circle with a black M
inside.


Conguring Nagios Server and
Add Windows Hosts
Now Login into Nagios Server and add some object
denitions in Nagios conguration les to monitor new
Windows machine. Open windows.cfg le for editing with Vi
editor.
Ho How Windo Lin Andro i iPho Ne Tech
me To ws ux id O ne ws Support
vi /usr/local/nagios/etc/objects/windows.cfg
S

A sample Windows host denition already dened for the


Windows machine, you can simply change the host denition
like host_name, alias, and address elds to appropriate
values of your Windows machine.

##################################################
########
##################################################
########
#
#HOSTDEFINITIONS
#
##################################################
########
##################################################
########
#Define ahostfortheWindowsmachinewe'llbe
monitoring
#Changethehost_name,alias,andaddresstofit
yoursituation
definehost{
usewindowsserverInheritdefault

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 29/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

valuesfromatemplate
host_namewinserverThenamewe're
givingtothishost
aliasMyWindowsServerAlonger
nameassociatedwiththehost
address172.31.41.53IPaddressof
thehost
}

Following services are already added and enabled in


windows.cfg le. If you wish to add some more other service
denitions that needs to be monitored, you can simple add
those denitions to same conguration le. Make sure to
change the host_name for these all services with host_name
dened in the above step.

dene service{
use generic-service
host_name winserver
service_description NSClient++ Version
Ho check_command
How Windo
check_nt!CLIENTVERSION
Lin Andro i iPho Ne Tech
me } To ws ux id O ne ws Support
S
Add the following service denition to monitor the uptime of
the Windows server.

dene service{
use generic-service
host_name winserver
service_description Uptime
check_command check_nt!UPTIME
}

Add the following service denition to monitor the CPU


utilization on the Windows server and generate a CRITICAL
alert if the 5-minute CPU load is 90% or more or a WARNING
alert if the 5-minute load is 80% or greater.

dene service{
use generic-service
host_name winserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

Add the following service denition to monitor memory usage


on the Windows server and generate a CRITICAL alert if
http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 30/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

memory usage is 90% or more or a WARNING alert if memory


usage is 80% or greater.

dene service{
use generic-service
host_name winserver
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}

Add the following service denition to monitor usage of the


C:\ drive on the Windows server and generate a CRITICAL
alert if disk usage is 90% or more or a WARNING alert if disk
usage is 80% or greater.

dene service{
use generic-service
host_name winserver
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
Ho How Windo Lin Andro i iPho Ne Tech
me To ws ux id O ne ws Support
Add the following service denition to monitor the W3SVC
S
service state on the Windows machine and generate a
CRITICAL alert if the service is stopped.

dene service{
use generic-service
host_name winserver
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l
W3SVC
}

Add the following service denition to monitor the


Explorer.exe process on the Windows machine and generate
a CRITICAL alert if the process is not running.

dene service{
use generic-service
host_name winserver
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l
Explorer.exe
}

Lastly, uncomment the windows.cfg le in

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 31/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

/usr/local/nagios/etc/nagios.cfg.

vi /usr/local/nagios/etc/nagios.cfg

# Denitions for monitoring a Windows machine


cfg_le=/usr/local/nagios/etc/objects/windows.cfg

Finally, verify the Nagios conguration les for any erros.

/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-ight check

If the verication process throws any error messages, x


those errors until the verication process completes without
any error messages. Once you x those errors, restart the
Ho How Windo Lin Andro i iPho Ne Tech
Nagios service.
me To ws ux id O ne ws Support
S
service nagios restart
Running conguration check...done.
Stopping nagios: done.
Starting nagios: done.

Now go to Nagios Monitoring Web interface at http://server-


ip-address/nagios or http://hostname/nagios and Provide
the username nagiosadmin and password. Check that the
Remote Windows Host was added and is being monitored.

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 32/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Conguring Nagios Server and


Add Network Switch or Router

You might also like:

HowtoSortExcel DontShutDown HowtoInstall HowtoReversea HowtoBypass


WorksheetTabsin YourComputer VagrantFreeTool Numberedor iCloudActivation
AlphabeticalOrder toAutomateVM BulletedListin onaniPhoneor
Provisioning MicrosoftWord iPad

Linkwithin

Ho Howto Add Windo


How and Lin Andro
How to Determine i iPho Ne Tech
me To
Monitor ws
Network ux the Presence
id of O ne ws Support

Switch, Router Bad Sectors on a S
Using Nagios Disk Drive in Linux

We encourage healthy criticism, so do not hesitate to leave


your thoughts in comment box.

Emoticon

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 33/34
23/11/2016 HowtoInstallNagios4.2.0onRedHat,CentOSorFedoraLinux

Enteryourcomment...

Commentas: Unknown(Google) Signout


Publish Preview Notifyme

Ho How Windo Lin Andro i iPho Ne Tech


me To ws ux id O ne ws Support
S


Copyright 2015 INFOSBIRD

http://www.infosbird.com/2016/11/howtoinstallnagios4.2.0onredhatcentosorferoralinux.html 34/34