You are on page 1of 18

NRPE Documentation

Copyright (c) 1999-2007 Ethan Galstad


Last Updated: May 1 2007

CONTENTS
Section 1! "ntrod#ction !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! a) $#rpose !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %) &esign '(er(ie) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Page 2 2 2

2! E*a+ple Uses !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! a) &irect Chec,s !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %) "ndirect Chec,s !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! "nstallation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! a) $rere.#isites !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %) /e+ote 0ost 1et#p !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! c) Monitoring 0ost 1et#p !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2 2 6 9

2! C#sto+i3ing 4o#r Con5ig#ration !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 16! Upgrading !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 16 7! 8ro#%leshooting !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 17

NRPE Documentation

1. INTRODUCTION
a) Purpose
8he 9/$E addon is designed to allo) yo# to e*ec#te 9agios pl#gins on re+ote Lin#*:Uni* +achines! 8he +ain reason 5or doing this is to allo) 9agios to +onitor ;local; reso#rces (li,e C$U load +e+ory #sage etc!) on re+ote +achines! 1ince these p#%lic reso#rces are not #s#ally e*posed to e*ternal +achines an agent li,e 9/$E +#st %e installed on the re+ote Lin#*:Uni* +achines! 9ote: "t is possi%le to e*ec#te 9agios pl#gins on re+ote Lin#*:Uni* +achines thro#gh 110! 8here is a check_by_ssh pl#gin that allo)s yo# to do this! Using 110 is +ore sec#re than the 9/$E addon %#t it also i+poses a larger (C$U) o(erhead on %oth the +onitoring and re+ote +achines! 8his can %eco+e an iss#e )hen yo# start +onitoring h#ndreds or tho#sands o5 +achines! Many 9agios ad+ins opt 5or #sing #sing the 9/$E addon %eca#se o5 the lo)er load it i+poses!

b) Design Overview

8he 9/$E addon consists o5 t)o pieces:


8he check_nrpe pl#gin )hich resides on the local +onitoring +achine 8he NRPE dae+on )hich r#ns on the re+ote Lin#*:Uni* +achine

<hen 9agios needs to +onitor a reso#rce o5 ser(ice 5ro+ a re+ote Lin#*:Uni* +achine:

9agios )ill e*ec#te the check_nrpe pl#gin and tell it )hat ser(ice needs to %e chec,ed 8he check_nrpe pl#gin contacts the NRPE dae+on on the re+ote host o(er an (optionally) 11L-protected connection 8he NRPE dae+on r#ns the appropriate 9agios pl#gin to chec, the ser(ice or reso#rce 8he res#lts 5ro+ the ser(ice chec, are passed 5ro+ the NRPE dae+on %ac, to the check_nrpe pl#gin )hich then ret#rns the chec, res#lts to the 9agios process!

9ote: 8he 9/$E dae+on re.#ires that 9agios pl#gins %e installed on the re+ote Lin#*:Uni* host! <itho#t these the dae+on )o#ldn=t %e a%le to +onitor anything!

Last Updated: May 1 2007

$age 2 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation

. E!"#P$E USES
a) Direct C%ec&s
8he +ost straight 5or)ard #se o5 the 9/$E addon is to +onitor ;local; or ;pri(ate; reso#rces on a re+ote Lin#*:Uni* Machine! 8his incl#des things li,e C$U load +e+ory #sage s)ap #sage c#rrent #sers dis, #sage process states etc!

b) In'irect C%ec&s
4o# can also #se the 9/$E addon to indirectly chec, ;p#%lic; ser(ices and reso#rces o5 re+ote ser(ers that +ight not %e reacha%le directly 5ro+ the +onitoring host! ?or instance i5 the re+ote host that the 9/$E dae+on and pl#gins are installed on can tal, to the a re+ote )e% ser(er (%#t the +onitoring host cannot) yo# can con5ig#re the 9/$E dae+on to allo) yo# to +onitor the re+ote )e% ser(er indirectly! 8he 9/$E dae+on is essentially acting as pro*y in this case!

Last Updated: May 1 2007

$age - o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation

(. INST"$$"TION
"n order to #se the 9/$E addon yo#=ll need to per5or+ so+e tas,s on %oth the +onitoring host and the re+ote Lin#*:Uni* host that the 9/$E dae+on is installed on! "=ll co(er %oth o5 these tas,s separately! 9ote: 8hese instr#ctions are %ased on a re+ote host r#nning ?edora Core 7! 9a+ing con(entions co++ands etc! (ary across di55erent Lin#* distros and U9"@ (ariants so the instr#ctions pro(ided here +ay ha(e to %e altered a %it 5or yo#r sit#ation! "5 yo#=re ha(ing tro#%le #sing these instr#ctions yo# can 5ind '1:distri%#tion-speci5ic installation g#ides 0'<8's and other help5#l installation doc#+entation on the 9agios Co++#nity )i,i at http:::)))!nagiosco++#nity!org:)i,i:!

a) Prere)uisites
"n order to co+plete these installation instr#ctions yo#=ll need:

/oot access on the re+ote Lin#*:Uni* host Access to the nagios #ser acco#nt on the +onitoring host

b) "ssumptions
8hese instr#ctions ass#+e that yo# are installing the 9/$E addon on a syste+ that s#pports 8C$ )rappers and has the *inetd s#perser(er installed! Most +odern Lin#* distri%#tions and Uni* (ariants ha(e these installed %y de5a#lt! "5 yo# ha(e an older syste+ that r#ns inetd (instead o5 *inetd) and:or does not s#pport 8C$ )rappers or yo# )ant to r#n the 9/$E dae+on )itho#t inetd or *inetd read the 5ollo)ing 5iles 5or in5or+ation on installing the addon (%oth are 5o#nd in the +ain directory o5 the 9/$E distri%#tion):

/EA&ME 1ECU/"84

B Contin#ed on ne*t page C

Last Updated: May 1 2007

$age 2 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
c) Remote *ost Setup
8hese instr#ctions sho#ld %e co+pleted on the re+ote Lin#*:Uni* host that the 9/$E dae+on )ill %e installed on! 4o#=ll %e installing the 9agios pl#gins and the 9/$E dae+on!!! i. Create "ccount In+ormation Deco+e the root #ser! 4o# +ay ha(e to #se sudo -s on U%#nt# and other distros!
su -l

Create a ne) nagios #ser acco#nt and gi(e it a pass)ord!


/usr/sbin/useradd nagios passwd nagios

ii. Insta,, t%e Nagios P,ugins Create a directory 5or storing the do)nloads!
mkdir ~/downloads cd ~/downloads

&o)nload the so#rce code tar%all o5 the 9agios pl#gins ((isit http:::)))!nagios!org:do)nload: 5or lin,s to the latest (ersions)! At the ti+e o5 )riting the latest sta%le (ersion o5 the 9agios pl#gins )as 1!2!7!
wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.6.tar.gz

E*tract the 9agios pl#gins so#rce code tar%all!


tar xzf nagios-plugins-1.4.6.tar.gz cd nagios-plugins-1.4.6

Co+pile and install the pl#gins!


./configure make make install

8he per+issions on the pl#gin directory and the pl#gins )ill need to %e 5i*ed at this point so r#n the 5ollo)ing co++ands!
chown nagios.nagios /usr/local/nagios chown - nagios.nagios /usr/local/nagios/libexec

iii. Insta,, -inet' ?edora Core 7 doesn=t ship )ith *inetd installed %y de5a#lt so install it )ith the 5ollo)ing co++and:
!um install xinetd

Last Updated: May 1 2007

$age 6 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
iv. Insta,, t%e NRPE 'aemon &o)nload the so#rce code tar%all o5 the 9/$E addon ((isit http:::)))!nagios!org:do)nload: 5or lin,s to the latest (ersions)! At the ti+e o5 )riting the latest (ersion o5 9/$E )as 2!>!
cd ~/downloads wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-".#.tar.gz

E*tract the 9/$E so#rce code tar%all!


tar xzf nrpe-".#.tar.gz cd nrpe-".#

Co+pile the 9/$E addon!


./configure make all

"nstall the 9/$E pl#gin (5or testing) dae+on and sa+ple dae+on con5ig 5ile!
make install-plugin make install-daemon make install-daemon-config

"nstall the 9/$E dae+on as a ser(ice #nder *inetd!


make install-xinetd

Edit the /etc/xinetd.d/nrpe 5ile and add the "$ address o5 the +onitoring ser(er to the only_from directi(e!
onl!$from % 1"&.'.'.1 (nagios$ip$address)

Add the 5ollo)ing entry 5or the 9/$E dae+on to the /etc/services 5ile!
nrpe *666/tcp + , -.

/estart the *inetd ser(ice!


ser/ice xinetd restart

Last Updated: May 1 2007

$age 7 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
v. Test t%e NRPE 'aemon ,oca,,. "ts ti+e to see i5 things are )or,ing properly!!! Ma,e s#re the nrpe dae+on is r#nning #nder *inetd!
netstat -at 0 grep nrpe

8he o#tp#t o#t this co++and sho#ld sho) so+ething li,e this:
tcp ' ' 1:nrpe 1:1 2345.,

"5 it does greatE "5 it doesn=t +a,e s#re o5 the 5ollo)ing:


4o# added the nrpe entry to yo#r /etc/services 5ile 8he only_from directi(e in the /etc/xinetd.d/nrpe 5ile contains an entry 5or ;127!0!0!1; *inetd is installed and started Chec, the syste+ log 5iles 5or re5erences a%o#t *inetd or nrpe and 5i* any pro%le+s that are reported

9e*t chec, to +a,e s#re the 9/$E dae+on is 5#nctioning properly! 8o do this r#n the check_nrpe pl#gin that )as installed 5or testing p#rposes!
/usr/local/nagios/libexec/check$nrpe -6 localhost

4o# sho#ld get a string %ac, that tells yo# )hat (ersion o5 9/$E is installed li,e this:
, -. /".#

vi. Open +irewa,, ru,es Ma,e s#re that the local 5ire)all on the +achine )ill allo) the 9/$E dae+on to %e accessed 5ro+ re+ote ser(ers! 8o do this r#n the 5ollo)ing ipta%les co++and! 9ote that the RH-Firew ll-!-"NP#$ chain na+e is ?edoraspeci5ic so it )ill %e di55erent on other Lin#* distri%#tions!
iptables -3 6-7irewall-1-3,-85 -p tcp -m tcp 9dport *666 -: ;<<.-5

1a(e the ne) ipta%les r#le so it )ill s#r(i(e +achine re%oots!


ser/ice iptables sa/e

Last Updated: May 1 2007

$age 7 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
vii. Customi/e NRPE comman's 8he sa+ple 9/$E con5ig 5ile that got installed contains se(eral co++and de5initions that yo#=ll li,ely #se to +onitor this +achine! 8he co++and de5initions are #sed to (s#rprise) de5ine co++ands that the 9/$E dae+on )ill r#n to +onitor local reso#rces and ser(ices! 8he sa+ple co++and de5initions r#n so+e o5 the pl#gins that )ere installed in step 2! 4o# can edit the co++and de5initions add ne) co++ands etc %y editing the 9/$E con5ig 5ile:
/i /usr/local/nagios/etc/nrpe.cfg

More in5or+ation on c#sto+i3ing the co++ands can %e 5o#nd on page 1- in the section titled ;C#sto+i3ing 4o#r Con5ig#ration;! ?or the ti+e %eing "=ll ass#+e yo#=re #sing the sa+ple co++ands that are de5ined! 4o# can test so+e o5 these %y r#nning the 5ollo)ing co++ands:
/usr/local/nagios/libexec/check$nrpe /usr/local/nagios/libexec/check$nrpe /usr/local/nagios/libexec/check$nrpe /usr/local/nagios/libexec/check$nrpe /usr/local/nagios/libexec/check$nrpe -6 -6 -6 -6 -6 localhost localhost localhost localhost localhost -c -c -c -c -c check$users check$load check$hda1 check$total$procs check$zombie$procs

At this point yo# are done installing and con5ig#ring 9/$E on the re+ote host! 9o) its ti+e to install a co+ponent and +a,e so+e con5ig#ration entries on yo#r +onitoring ser(er!!! B Contin#ed on ne*t page C

Last Updated: May 1 2007

$age > o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
') #onitoring *ost Setup
'n the +onitoring host (the +achine that r#ns 9agios) yo#=ll need to do F#st a 5e) things:

"nstall the chec,Gnrpe pl#gin Create a 9agios co++and de5inition 5or #sing the chec,Gnrpe pl#gin Create 9agios host and ser(ice de5initions 5or +onitoring the re+ote host

8hese instr#ctions ass#+e that yo# ha(e already installed 9agios on this +achine according to the .#ic,start installation g#ide! 8he con5ig#ration e*a+ples that are gi(en re5erence te+plates that are de5ined in the sa+ple loc lhost.cf% and comm nds.cf% 5iles that get installed i5 yo# 5ollo) the .#ic,start! i. Insta,, t%e c%ec&0nrpe p,ugin Deco+e the root #ser! 4o# +ay ha(e to #se sudo -s on U%#nt# and other distros!
su -l

Create a directory 5or storing the do)nloads!


mkdir ~/downloads cd ~/downloads

&o)nload the so#rce code tar%all o5 the 9/$E addon ((isit http:::)))!nagios!org:do)nload: 5or lin,s to the latest (ersions)! At the ti+e o5 )riting the latest (ersion o5 9/$E )as 2!>!
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-".#.tar.gz

E*tract the 9/$E so#rce code tar%all!


tar xzf nrpe-".#.tar.gz cd nrpe-".#

Co+pile the 9/$E addon!


./configure make all

"nstall the 9/$E pl#gin!


make install-plugin

Last Updated: May 1 2007

$age 9 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
ii. Test communication wit% t%e NRPE 'aemon Ma,e s#re the chec,Gnrpe pl#gin can tal, to the 9/$E dae+on on the re+ote host! /eplace ;192!17>!0!1; in the co++and %elo) )ith the "$ address o5 the re+ote host that has 9/$E installed! :#sr:local:nagios:li%e*ec:chec,Gnrpe -0 192!17>!0!1 4o# sho#ld get a string %ac, that tells yo# )hat (ersion o5 9/$E is installed on the re+ote host li,e this:
, -. /".#

"5 the pl#gin ret#rns a ti+eo#t error chec, the 5ollo)ing:


Ma,e s#re there isn=t a 5ire)all %et)een the re+ote host and the +onitoring ser(er that is %loc,ing co++#nication Ma,e s#re that the 9/$E dae+on is installed properly #nder *inetd Ma,e s#re the re+ote host doesn=t ha(e local (ipta%les) 5ire)all r#les that pre(ent the +onitoring ser(er 5ro+ tal,ing to the 9/$E dae+on

iii. Create a comman' 'e+inition 4o#=ll need to create a co++and de5inition in one o5 yo#r 9agios o%Fect con5ig#ration 5iles in order to #se the chec,Gnrpe pl#gin! 'pen the sa+ple comm nds.cf% 5ile 5or editing!!!
/i /usr/local/nagios/etc/commands.cfg

and add the 5ollo)ing de5inition to the 5ile:


define command= command$name command$line B check$nrpe >84. 1>/check$nrpe -6 >6?45;@@ .44> -c >; A1>

4o# are no) ready to start adding ser(ices that sho#ld %e +onitored on the re+ote +achine to the 9agios con5ig#ration!!!

Last Updated: May 1 2007

$age 10 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
iv. Create %ost an' service 'e+initions 4o#=ll need to create so+e o%Fect de5initions in order to +onitor the re+ote Lin#*:Uni* +achine! 8hese de5initions can %e placed in their o)n 5ile or added to an already e*iting o%Fect con5ig#ration 5ile! ?irst its %est practice to create a ne) te+plate 5or each di55erent type o5 host yo#=ll %e +onitoring! Let=s create a ne) te+plate 5or lin#* %o*es!
define host= name use check$period check$inter/al retr!$inter/al max$check$attempts check$command notification$period notification$inter/al notification$options contact$groups register B linux-box generic-host "4x& * 1 1' check-host-ali/e "4x& D' dEr admins ' C @?,5 C ,ame of this template C 3nherit default /alues

.A345.

5634 - 354 ; 5.F-2;5.

9otice that the lin#*-%o* te+plate de5inition is inheriting de5a#lt (al#es 5ro+ the generic-host te+plate )hich is de5ined in the sa+ple loc lhost.cf% 5ile that gets installed )hen yo# 5ollo) the 9agios .#ic,start installation g#ide! 9e*t de5ine a ne) host 5or the re+ote Lin#*:Uni* %o* that re5erences the ne)ly created lin#*-%o* host te+plate!
define host= use host$name alias address B linux-box remotehost 7edora <ore 6 1H".16#.'.1 C C C C 3nherit default /alues from a template 5he name weGre gi/ing to this ser/er ; longer name for the ser/er 3- address of the ser/er

9e*t de5ine so+e ser(ices 5or +onitoring the re+ote Lin#*:Uni* %o*! 8hese e*a+ple ser(ice de5initions )ill #se the sa+ple co++ands that ha(e %een de5ined in the nrpe!c5g 5ile on the re+ote host! 8he 5ollo)ing ser(ice )ill +onitor the C$U load on the re+ote host! 8he ;chec,Gload; arg#+ent that is passed to the chec,Gnrpe co++and de5inition tells the 9/$E dae+on to r#n the ;chec,Gload; co++and as de5ined in the nrpe!c5g 5ile!
define ser/ice= use host$name ser/ice$description check$command B generic-ser/ice remotehost <-8 2oad check$nrpeIcheck$load

8he 5ollo)ing ser(ice )ill +onitor the the n#+%er o5 c#rrently logged in #sers on the re+ote host!
define ser/ice= use host$name ser/ice$description check$command B generic-ser/ice remotehost <urrent 8sers check$nrpeIcheck$users

8he 5ollo)ing ser(ice )ill +onitor the 5ree dri(e space on :de(:hda1 on the re+ote host!
define ser/ice= use host$name ser/ice$description check$command B generic-ser/ice remotehost /de//hda1 7ree 4pace check$nrpeIcheck$hda1

Last Updated: May 1 2007

$age 11 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
8he 5ollo)ing ser(ice )ill +onitor the total n#+%er o5 processes on the re+ote host!
define ser/ice= use host$name ser/ice$description check$command B generic-ser/ice remotehost 5otal -rocesses check$nrpeIcheck$total$procs

8he 5ollo)ing ser(ice )ill +onitor the n#+%er o5 3o+%ie processes on the re+ote host!
define ser/ice= use host$name ser/ice$description check$command B generic-ser/ice remotehost Jombie -rocesses check$nrpeIcheck$zombie$procs

8hose are the %asic ser(ice de5initions 5or +onitoring the re+ote host! "5 yo# )o#ld li,e to add additional ser(ices to %e +onitored read the ;C#sto+i3ing 4o#r Con5ig#ration; section starting on page 1-!

v. Restart Nagios At this point yo#=(e installed the chec,Gnrpe pl#gin and addon host and ser(ice de5initions 5or +onitoring the re+ote Lin#*:Uni* +achine! 9o) its ti+e to +a,e those changes li(e!!! Heri5y yo#r 9agios con5ig#ration 5iles!
/usr/local/nagios/bin/nagios -/ /usr/local/nagios/etc/nagios.cfg

"5 there are errors 5i* the+! "5 e(erything is 5ine restart 9agios!
ser/ice nagios restart

8hat=s itE 4o# sho#ld see the host and ser(ice de5initions yo# created in the 9agios )e% inter5ace! "n a 5e) +in#tes 9agios sho#ld ha(e the c#rrent stat#s in5or+ation 5or the re+ote Lin#*:Uni* +achine! 1ince yo# +ight )ant to +onitor +ore ser(ices on the re+ote +achine " )o#ld s#ggest yo# read the ne*t section as )ell! :-) Also )hen it co+es ti+e to #pgrade the (ersion o5 9/$E yo#=re r#nning its pretty easy to do! 8he initial installation )as the to#ghest %#t #pgrading is a snap!

Last Updated: May 1 2007

$age 12 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation

1. CUSTO#I2IN3 4OUR CON5I3UR"TION


4o#=ll +ight )ant to +onitor +ore ser(ices on the re+ote Lin#*:Uni* %o* than those that are descri%ed in this doc#+entation! 8his is easy to acco+plish! Anyti+e yo# )ant to +onitor a ne) ser(ice on a re+ote host #sing the 9/$E addon yo# ha(e to do t)o things: 1! Add a ne) co++and de5inition to the nrpe!c5g 5ile on the re+ote host 2! Add a ne) ser(ice de5inition to yo#r 9agios con5ig#ration on the +onitoring host Let=s say yo# )ant to +onitor the s)ap #sage on the re+ote Lin#*:Uni* host! 0ere are the steps yo#=d need to 5ollo)!!!

a) Remote *ost Con+iguration


4o# can #se the check_sw p pl#gin to +onitor s)ap #sage on the +achine! Ass#+ing yo# 5ollo)ed the installation instr#ctions in this doc#+ent the check_sw p pl#gin sho#ld already %e installed in /&sr/loc l/n %ios/libexec! Login as the nagios #ser on the re+ote host! /#n the check_sw p pl#gin +an#ally and t)ea, the co++and line options to speci5y the desired )arning and critical 5ree s)ap space thresholds! Ma,e s#re the 5#ll co++and line ret#rns the e*pected o#tp#t yo# )ant 5ro+ the pl#gin! ?or this e*a+ple let=s say yo# )ant a critical alert i5 s)ap 5ree space is less than 10I and a )arning i5 5ree space is less than 20I! 0ere=s the co++and line that )o#ld acco+plish that:
/usr/local/nagios/libexec/check$swap -w "'K -c 1'K

9o) that yo# ,no) the co++and line that sho#ld %e e*ec#te open the 9/$E con5ig#ration 5ile!
/i /usr/local/nagios/etc/nrpe.cfg

Add a ne) check_sw p co++and de5inition that #ses the co++and line 5ro+ a%o(e and sa(e the 5ile!
commandLcheck$swapM%/usr/local/nagios/libexec/check$swap -w "'K -c 1'K

"5 yo#=re r#nning the 9/$E dae+on as a standalone dae+on yo#=ll need to restart it! "5 yo#=re r#nning it #nder the inetd:*inetd s#perser(er yo# don=t need to do anything +ore!

Last Updated: May 1 2007

$age 1- o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
b) #onitoring *ost Con+iguration
'n the +onitoring host yo# need to de5ine a ne) ser(ice 5or +onitoring the s)ap #sage on the re+ote host! Add the 5ollo)ing entry to one o5 yo#r o%Fect con5ig#ration 5iles!
define ser/ice= use host$name ser/ice$description check$command B generic-ser/ice remotehost 4wap 8sage check$nrpeIcheck$swap

9otice that the chec, co++ands is passing ;chec,Gs)ap; to the check_nrpe co++and de5inition! 8his )ill ca#se the 9/$E dae+on to r#n the check_sw p co++and that )as de5ined in the nrpe!c5g 5ile on the re+ote host in the pre(io#s step! 9e*t (eri5y yo#r 9agios con5ig#ration 5iles and restart 9agios!
/usr/local/nagios/bin/nagios -/ /usr/local/nagios/etc/nagios.cfg ser/ice nagios restart

8hat=s itE 4o# are no) +onitoring a ne) ser(ice on the re+ote host #sing the 9/$E addon!

Last Updated: May 1 2007

$age 12 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation

6. UP3R"DIN3
At so+e point in ti+e yo#=ll )ant to #pgrade the (ersion o5 the 9/$E addon that yo#=re r#nning! 8he #pgrade process is 5airly pain 5ree! 0ere are the details!!!

a) #onitoring *ost Upgra'e


'n the +onitoring host (the +achine that r#ns 9agios) yo# only ha(e to #pgrade the chec,Gnrpe pl#gin! 0ere=s ho)!!! Login as the nagios #ser and create a directory 5or storing the do)nloads!
mkdir ~/downloads cd ~/downloads

&o)nload the so#rce code tar%all o5 the 9/$E addon ((isit http:::)))!nagios!org:do)nload: 5or lin,s to the latest (ersions)! At the ti+e o5 )riting the latest (ersion o5 9/$E )as 2!>!
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-".#.tar.gz

E*tract the 9/$E so#rce code tar%all!


tar xzf nrpe-".#.tar.gz cd nrpe-".#

Co+pile the 9/$E addon!


./configure make all

"nstall the 9/$E pl#gin!


make install-plugin

4o#=re done on the +onitoring ser(erE

B Contin#ed on 9e*t $age C

Last Updated: May 1 2007

$age 16 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
b) Remote *ost Upgra'es
4o#=ll need to #pgrade the 9/$E dae+ons on all re+ote hosts that are %eing +onitored #sing the 9/$E addon! 0ere=s ho)!!! Login as the nagios #ser and create a directory 5or storing the do)nloads!
mkdir ~/downloads cd ~/downloads

&o)nload the so#rce code tar%all o5 the 9/$E addon ((isit http:::)))!nagios!org:do)nload: 5or lin,s to the latest (ersions)! At the ti+e o5 )riting the latest (ersion o5 9/$E )as 2!>!
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-".#.tar.gz

E*tract the 9/$E so#rce code tar%all!


tar xzf nrpe-".#.tar.gz cd nrpe-".#

Co+pile the 9/$E addon!


./configure make all

"nstall the 9/$E dae+on!


make install-daemon

"5 yo#=re r#nning the 9/$E dae+on as a standalone dae+on 5irst ,ill the old dae+on process and then start the (ne)) dae+on #p again! 4o#=re done )ith the #pgrade on the re+ote hostE

Last Updated: May 1 2007

$age 17 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation

7. TROU8$ES*OOTIN3
0ere are so+e tips 5or tro#%leshooting so+e o5 the +ore co++on errors )ith the 9/$E addon! "5 yo# enco#nter pro%le+s that aren=t co(ered here send an e+ail to the n %ios-&sers +ailing list! More in5or+ation on the +ailing lists can %e 5o#nd at: http:::)))!nagios!org:s#pport: T%e c%ec&0nrpe p,ugin returns 9C*EC:0NRPE; Soc&et timeout a+ter 1< secon's9 or 9Connection re+use' or time' out9 8his error can indicate se(eral things:

8he co++and that the 9/$E dae+on )as as,ed to r#n too, longer than 10 seconds to e*ec#te! 8his is the +ost li,ely ca#se i5 the error +essage )as ;C0ECJG9/$E: 1oc,et ti+eo#t a5ter 10 seconds;! Use the -t co++and line option to speci5y a longer ti+eo#t 5or the chec,Gnrpe pl#gin! 8he 5ollo)ing e*a+ple )ill increase the ti+eo#t to -0 seconds:
/usr/local/nagios/check$nrpe -6 localhost -c somecommand -t D'

8he 9/$E dae+on is not installed or r#nning on the re+ote host! Heri5y that the 9/$E dae+on is r#nning as a standalone dae+on or #nder inetd:*inetd )ith one o5 the 5ollo)ing co++ands:
ps axuw 0 grep nrpe netstat -at 0 grep nrpe

8here is a 5ire)all that is %loc,ing the co++#nication %et)een the +onitoring host ()hich r#ns the chec,Gnrpe pl#gin) and the re+ote host ()hich r#ns the 9/$E dae+on)! Heri5y that the 5ire)all r#les (e!g! ipta%les) that are r#nning on the re+ote host allo) 5or co++#nication and +a,e s#re there isn=t a physical 5ire)all that is located %et)een the +onitoring host and the re+ote host!

T%e c%ec&0nrpe p,ugin returns 9C*EC:0NRPE; Receive' < b.tes +rom 'aemon. C%ec& t%e remote server ,ogs +or an error message.9 ?irst thing yo# sho#ld do is chec, the re+ote ser(er logs 5or an error +essage! 1erio#sly! :-) 8his error co#ld %e d#e to the 5ollo)ing pro%le+:

8he chec,Gnrpe pl#gin )as #na%le to co+plete an 11L handsha,e )ith the 9/$E dae+on! An error +essage in the logs sho#ld indicate )hether or not this )as the case! Chec, the (ersions o5 'pen11L that are installed on the +onitoring host and re+ote host! "5 yo#=re r#nning a co++ercial (ersion o5 11L on the re+ote host there +ight %e so+e co+pati%ility pro%le+s!

T%e c%ec&0nrpe p,ugin returns 9NRPE; Unab,e to rea' output9 8his error indicates that the co++and that )as r#n %y the 9/$E dae+on did not ret#rn any character o#tp#t! 8his co#ld %e an indication o5 the 5ollo)ing pro%le+s:

An incorrectly de5ined co++and line in the co++and de5inition! Heri5y that the co++and de5inition in yo#r 9/$E con5ig#ration 5ile is correct! 8he pl#gin that is speci5ied in the co++and line is +al5#nctioning! /#n the co++and line +an#ally to +a,e s#re the pl#gin ret#rns so+e ,ind o5 te*t o#tp#t!

Last Updated: May 1 2007

$age 17 o5 1>

Copyright (c) 1999-2007 Ethan Galstad

NRPE Documentation
T%e c%ec&0nrpe p,ugin returns 9NRPE; Comman' =-= not 'e+ine'9 8his error +eans that yo# didn=t de5ine co++and x in the 9/$E con5ig#ration 5ile on the re+ote host! 'n the re+ote host add the co++and de5inition 5or x! 1ee the e*isting co++and de5initions in the 9/$E con5ig#ration 5ile 5or +ore in5or+ation on doing this! "5 yo#=re r#nning the 9/$E dae+on as a standalone dae+on (and not #nder inetd or *inetd) yo#=ll need to restart it in order 5or the ne) co++and to %e recogni3ed! T%e c%ec&0nrpe p,ugin returns 9NRPE; Comman' time' out a+ter - secon's9 8his error indicates that the co++and that )as r#n %y the 9/$E dae+on did not 5inish e*ec#ting )ithin the speci5ied ti+e! 4o# can increase the ti+eo#t 5or co++ands %y editing the 9/$E con5ig#ration 5ile and changing the (al#e o5 the comm nd_timeo&t (aria%le! "5 yo#=re r#nning the 9/$E dae+on as a standalone dae+on (and not #nder inetd or *inetd) yo#=ll need to restart it in order 5or the ne) ti+eo#t to %e recogni3ed! *ow to go about 'ebugging ot%er prob,ems... <hen de%#gging pro%le+s it +ay %e #se5#l to edit the 9/$E con5ig#ration 5ile and change the deb&%'( entry to deb&%'!! 'nce yo# do that restart the 9/$E dae+on i5 it is r#nning as a standalone dae+on! A5ter yo# try #sing the chec,Gnrpe pl#gin again yo# sho#ld %e a%le to see so+e de%#gging in5or+ation in the log 5iles o5 the re+ote host! Chec, yo#r logs care5#lly K they sho#ld %e a%le to help pro(ide cl#es as to )here the pro%le+ lies!!!

Last Updated: May 1 2007

$age 1> o5 1>

Copyright (c) 1999-2007 Ethan Galstad

You might also like