Sie sind auf Seite 1von 6

How to monitor remote Linux host using Nagios 3.

0
Posted on June 1st, 2008 by Ramesh
Filed Under: Linux Tags: nagios
n the !re"ious !ost #agios $%0 Jum!start guide , ex!lained the o"er"ie&, installation and 'on(iguration
o( #agios $%0 on Red )at *er"er% n the (ollo&ing three 'ha!ters, +ll ex!lain ho& to monitor a remote
Linux host and the "arious ser"i'es running on the remote host%
% ,"er"ie&
% - ste!s to install #agios !lugin and #RP. on remote host%
1% /o&nload #agios Plugins and #RP. 0dd1on
2% 2reate nagios a''ount
$% nstall #agios Plugins
3% nstall #RP.
4% *etu! #RP. to run as daemon
-% 5odi(y the 6usr6lo'al6nagios6et'6nr!e%'(g
% 3 2on(iguration ste!s on the #agios monitoring ser"er to monitor remote host:
1% /o&nload #RP. 0dd1on
2% nstall 'he'78nr!e
$% 2reate host and ser"i'e de(inition (or remote host
3% Restart the nagios ser"i'e
I. Overview:
%
Follo&ing three ste!s &ill ha!!en on a "ery high le"el &hen #agios 9installed on the nagios1ser"ers:
monitors a ser"i'e 9(or e%g% dis7 s!a'e usage: on the remote Linux host%
1% #agios &ill exe'ute 'he'78nr!e 'ommand on nagios1ser"er and re;uest it to monitor dis7 usage
on remote host using 'he'78dis7 'ommand%
2% The 'he'78nr!e on the nagios1ser"er &ill 'onta't the #RP. daemon on remote host and re;uest it
to exe'ute the 'he'78dis7 on remote host%
$% The results o( the 'he'78dis7 'ommand &ill be returned ba'7 by #RP. daemon to the 'he'78nr!e
on nagios1ser"er%
Follo&ing (lo& summari<es the abo"e ex!lanation:
#agios *er"er 9'he'78nr!e: =>? Remote host 9#RP. deamon: =>? 'he'78dis7
#agios *er"er 9'he'78nr!e: @=> Remote host 9#RP. deamon: @=> 'he'78dis7 9returns dis7 s!a'e
usage:
II. 7 steps to install Nagios Plugins and NRP on the remote host
%
!. "ownload Nagios Plugins and NRP #dd$on
/o&nload (ollo&ing (iles (rom #agios%org and mo"e to 6home6do&nloads:
nagios1!lugins11%3%11%tar%g<
nr!e12%12%tar%g<
%. &reate nagios a''ount
AremotehostBCuseradd nagios
AremotehostBC!ass&d nagios
3. Install nagios$plugin
AremotehostBC'd 6home6do&nloads
AremotehostBC tar x"(< nagios1!lugins11%3%11%tar%g<
AremotehostBC 'd nagios1!lugins11%3%11
AremotehostBC ex!ort L/FL0D*E1ldl
AremotehostBC 'on(igure >&ith1nagios1userEnagios >&ith1nagios1grou!Enagios >enable1redhat1!thread1
&or7around
AremotehostBC ma7e
AremotehostBC ma7e install
AremotehostBC 'ho&n nagios%nagios 6usr6lo'al6nagios
AremotehostBC 'ho&n 1R nagios%nagios 6usr6lo'al6nagios6libexe'6
Note: ,n Red )at, For me the %6'on(igure 'ommand &as hanging &ith the the message: ('he')ing *or
redhat spopen pro+lem,-. 0dd >enable1redhat1!thread1&or7around to the %6'on(igure 'ommand as a
&or71around (or the abo"e !roblem%
.. Install NRP
AremotehostBC'd 6home6do&nloads
AremotehostBC tar x"(< nr!e12%12%tar%g<
AremotehostBC 'd nr!e12%12
AremotehostBC 'on(igure
AremotehostBC ma7e all
AremotehostBC ma7e install1!lugin
AremotehostBC ma7e install1daemon
AremotehostBC ma7e install1daemon1'on(ig
AremotehostBC ma7e install1xinetd
/. 0etup NRP to run as daemon 1i.e as part o* xinetd2:
5odi(y the 6et'6xinetd%d6nr!e to add the i!1address o( the #agios monitoring ser"er to the
only8(rom dire'ti"e% #ote that there is a s!a'e a(ter the 12F%0%0%1 and the nagios monitoring ser"er
i!1address 9in this exam!le, nagios monitoring ser"er i!1address is: 1G2%1-8%1%2:
only_from = 127.0.0.1 192.168.1.2
5odi(y the 6et'6ser"i'es and add the (ollo&ing at the end o( the (ile%
nrpe 5666/tcp # NRPE
*tart the ser"i'e
[remotehot!#er"#ce $#net% ret&rt
Heri(y &hether #RP. is listening
[remotehot!# nett&t '&t ( )rep nrpe
tcp 0 0 *+nrpe *+* ,-./EN
Heri(y to ma7e sure the #RP. is (un'tioning !ro!erly
[remotehot!# /0r/loc&l/n&)#o/l#1e$ec/chec2_nrpe '3 loc&lhot
NRPE "2.12
3. 4odi*5 the 6usr6lo'al6nagios6et'6nrpe.'*g
The nr!e%'(g (ile lo'ated on the remote host 'ontains the 'ommands that are needed to 'he'7 the ser"i'es
on the remote host% Iy de(ault the nr!e%'(g 'omes &ith (e& standard 'he'7 'ommands as sam!les%
'he'78users and 'he'78load are sho&n belo& as an exam!le%
'ommandA'he'78usersBE6usr6lo'al6nagios6libexe'6'he'78users 1& 4 1' 10
'ommandA'he'78loadBE6usr6lo'al6nagios6libexe'6'he'78load 1& 14,10,4 1' $0,24,20
n all the 'he'7 'ommands, the J1&K stands (or JLarningK and J1'K stands (or J2riti'alK% (or e%g% in the
'he'78dis7 'ommand belo&, i( the a"ailable dis7 s!a'e gets to 20M o( less, nagios &ill send &arning
message% ( it gets to 10M or less, nagios &ill send 'riti'al message% 2hange the "alue o( J1'K and J1&K
!arameter belo& de!ending on your en"ironment%
'ommandA'he'78dis7BE6usr6lo'al6nagios6libexe'6'he'78dis7 1& 20M 1' 10M 1! 6de"6hda1
Note: Nou 'an exe'ute any o( the 'ommands sho&n in the nr!e%'(g on the 'ommand line on remote host
and see the results (or yoursel(% For e%g% Lhen exe'uted the 'he'78dis7 'ommand on the 'ommand line,
it dis!layed the (ollo&ing:
AremotehostBC6usr6lo'al6nagios6libexe'6'he'78dis7 1& 20M 1' 10M 1! 6de"6hda1
"I07 &RI8I&#L 1 *ree spa'e: 6 3.%0 49 9!0: inodeEG8M:OP 6E440$25IO41FG2O482--O0O-3F31
n the abo"e exam!le, sin'e the (ree dis7 s!a'e on 6de"6hda1 is only 10M , it is dis!laying the 2RT20L
message, &hi'h &ill be returned to nagios ser"er%
III. . &on*iguration steps on the Nagios monitoring server to
monitor remote host:
%
!. "ownload NRP #dd$on
/o&nload nr!e12%12%tar%g< (rom #agios%org and mo"e to 6home6do&nloads:
%. Install 'he');nrpe on the nagios monitoring server
Anagios1ser"erBC tar x"(< nr!e12%12%tar%g<
Anagios1ser"erBC 'd nr!e12%1%2
Anagios1ser"erBC %6'on(igure
Anagios1ser"erBC ma7e all
Anagios1ser"erBC ma7e install1!lugin
%6'on(igure &ill gi"e a 'on(iguration summary as sho&n belo&:
QQQ 2on(iguration summary (or nr!e 2%12 041$112008 QQQ:
Deneral ,!tions:
========1
#RP. !ort: 4---
#RP. user: nagios
#RP. grou!: nagios
#agios user: nagios
#agios grou!: nagios
Note: got the J'he')ing *or 00L headers, 'on*igure: error: &annot *ind ssl headersK error message
&hile !er(orming %6'on(igure% nstall o!enssl1de"el as sho&n belo& and run the %6'on(igure again to (ix the
!roblem%
Anagios1ser"erBC r!m 1i"h o!enssl1de"el10%G%Fa13$%1-%i$8-%r!m 7rb41de"el11%$%313F%i$8-%r!m <lib1de"el1
1%2%1%211%2%i$8-%r!m e2(s!rogs1de"el11%$4112%4%
el3%i$8-%r!m
&arning: o!enssl1de"el10%G%Fa13$%1-%i$8-%r!m: H$ /*0 signature: #,R.N, 7ey / db32a-0e
Pre!aringS CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC A100MB
1:e2(s!rogs1de"el CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC A 24MB
2:7rb41de"el CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC A 40MB
$:<lib1de"el CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC A F4MB
3:o!enssl1de"el CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC A100MB
Heri(y &hether nagios monitoring ser"er 'an tal7 to the remotehost%
Anagios1ser"erBC6usr6lo'al6nagios6libexe'6'he'78nr!e 1) 1G2%1-8%1%$
#RP. "2%12
#ote: 1G2%1-8%1%$ in the i!1address o( the remotehost &here the #RP. and nagios !lugin &as installed as
ex!lained in *e'tion abo"e%
3. &reate host and servi'e de*inition *or remotehost
2reate a ne& 'on(iguration (ile 6usr6lo'al6nagios6et'6o+<e'ts6remotehost.'*g to de(ine the host and
ser"i'e de(inition (or this !arti'ular remotehost% t is good to ta7e the lo'alhost%'(g and 'o!y it as
remotehost%'(g and start modi(ying it a''ording to your needs%
host de*inition sample:
de(ine hostT
use linux1ser"er
host8name remotehost
alias Remote )ost
address 1G2%1-8%1%$
'onta't8grou!s admins
U
0ervi'e de*inition sample:
de(ine ser"i'eT
use generi'1ser"i'e
ser"i'e8des'ri!tion Root Partition
'onta't8grou!s admins
'he'78'ommand 'he'78nr!eV'he'78dis7
U
#ote: n all the abo"e exam!les, re!la'e remotehost &ith the 'orres!onding hostname o( your remotehost%
.. Restart the nagios servi'e
Restart the nagios as sho&n belo& and login to the nagios &eb 9htt!:66nagios1ser"er6nagios6: to "eri(y the
status o( the remotehost linux se"er that &as added to nagios (or monitoring%
Anagios1ser"erBCser"i'e nagios reload
Help me spread the news a+out m5 +log
( you li7e this !ost, &ould sin'erel5 appre'iate i( you 'an s!read the &ord around about JThe Dee7
*tu((K blog by adding it to del%i'io%us or /igg through the lin7 belo&%

Das könnte Ihnen auch gefallen