Вы находитесь на странице: 1из 17

GUIADE

INSTALAOE
CONFIGURAO
DONAGIOS
LINUX
NDICE
1PRINSTALAO......................................................................................................................3
1.1ONagios............................................................................................................................3
1.2Requisitos...........................................................................................................................3
1.3Licena...............................................................................................................................3

1.4Observaes.......................................................................................................................3
2INSTALAO...............................................................................................................................4
2.1Adiodousurio/grupo'nagios'aoSistema.....................................................................4
2.2Download,DescompactaoeInstalaodoNagiosedosplugins...................................4
2.3ConfiguraodaInterfaceWebApache.........................................................................5
2.4ConfiguraodoNagios.....................................................................................................6
2.4.1Configuraoutilizandoseoarquivominimal.cfg...............................................6
2.4.2Configuraoutilizandosearquivosespecficosparacadaitem..........................6
2.4.2.1nagios.cfg..................................................................................................7
2.4.2.2cgi.cfg........................................................................................................7
2.4.2.3timeperiods.cfg..........................................................................................7
2.4.2.4checkcommands.cfg..................................................................................7
2.4.2.5contacts.cfg................................................................................................8
2.4.2.6contactgroups.cfg......................................................................................8
2.4.2.7hosts.cfg.....................................................................................................8
2.4.2.8hostgroups.cfg...........................................................................................9
2.4.2.9services.cfg................................................................................................9
2.5ChecagemdaConfiguraoeInicializaodoNagios....................................................11
2.6MonitoramentodaRede...................................................................................................12
2.7ExecuodePluginsemHostsRemotosAddonNRPE...............................................12
2.7.1Adiodousurio/grupo'nagios'aosHostsRemotos.........................................12
2.7.1.1HostRemotoLinux.................................................................................12
2.7.1.2HostRemotoFreeBSD............................................................................12
2.7.2Download,InstalaoeConfiguraodoNRPEnosHostsRemotos.................13
2.7.2.1HostRemotoLinux.................................................................................13
2.7.2.2HostRemotoFreeBSD............................................................................13
2.7.2.3AmbosLinuxeFreeBSD........................................................................14
2.7.3ConfiguraodoNRPEnoHostLocal(Nagios).................................................14
2.7.4InicializaodoNRPEnosHostsRemotos.........................................................16
2.8InicializaoAutomticadoSistemadeMonitoramento................................................16
2.8.1IniciandooNagioscomoBootdoSistema(HostLocal)...................................16
2.8.2IniciandooNRPEcomoBootdoSistema(HostsRemotos)..............................17
2.8.2.1Mtodo1INETDouXINETD.............................................................17
2.8.2.2Mtodo2EdiodeArquivosdeInicializao...................................17
2.8.2.2.1HostRemotoLinux(Arquivorc.local).......................................17
2.8.2.2.2HostRemotoFreeBSD(Arquivorc.conf)..................................17

1 PR-INSTALAO
1.1 O Nagios
ONagiosumaplicativodemonitoramentodesistemasederedes.Elechecaclienteseservios,porvocespecificados,alertando
quandoascoisasestoindomalouserestabelecendo.
ONagiosfoioriginalmentedesenhadopararodarnoLinux,apesardelepoderfuncionarnamaioriadosunices.Paramais
informaessobreemqualsistemaoperacionaloNagiosir,ouno,funcionar,vejaapginadeportabilidadeemsistemasoperacionais,
acessvelemhttp://www.nagios.org/ports.shtml.
AlgumadasvriasferramentasdoNagiosincluem:

Monitoramentoderedeeservios(SMTP,POP3,HTTP,NNTP,PING,etc.);
Monitoramentodosrecursosdeclientes(cargadeprocessador,usodedisco,etc.);
Organizaosimplesdepluginsquepermiteaosusuriosdesenvolveremseusprpriosserviosdechecagem;
Checagemparaleladeservios;
Habilidadeparadefinirhierarquiaderedesdeclientesusandoclientespais(parenthosts),permitindoadetecoedistino
entreclientesqueestodesativadoseaquelesqueestoinalcanveis;
Notificaodecontatosquandoproblemasemservioseclientesocorreremouforemresolvidos(viaemail,pager,ou
mtodosdefinidospelousurio);
Habilidadeparadefinirtratadoresdeeventos(eventhandlers)queseroexecutadosduranteeventosdeserviosouclientes
natentativaderesoluodeproblemas;
Rotatividadeautomticadearquivosdelogs;
Suporteparaimplementaodeclientesdemonitoramentoredundantes;
Interfacewebparavisualizaodostatusatualdarede,histricodenotificaeseproblemas,arquivosdelog,etc.

1.2 Requisitos
AnicaexignciapararodaroNagiosterumcomputadorrodandoLinux(ouvariantesdoUNIX)eumcompiladorC.Voc
provavelmentenecessitarteroTCP/IPconfiguradojqueamaioriadaschecagensdeserviosserofeitasatravsdarede.
VocnoobrigadoausarosCGIsincludoscomoNagios.Noentanto,sevocoptarporuslos,vocprecisardosseguintes
programasinstalados:
1)UmservidorWeb(deprefernciaApache);
2)BibliotecaGD(gdlibrary)deThomasBoutellverso1.6.3ousuperior(exigidapelasCGIsstatusmapetrends).

1.3 Licena
ONagiosdistribudosobostermosdaGNUGeneralPublicLicenseVerso2comofoipublicadopelaFreeSoftwareFoundation.
Istolhegarantepermissodecopiar,distribuiremodificaroNagiossobcertascondies.Leiaoarquivo'LICENSE'queveiona
distribuiodoNagiosouleiaaversoonlinedalicenaparamaioresdetalhes.
ONagiosfornecidoSEMQUALQUERGARANTIADEQUALQUERTIPO,INCLUINDOAGARANTIADEDESENHO,
MECANTIBILIDADEEADEQUAOPARAUMPROPSITOPARTICULAR.

1.4 Observaes
OManualdoNagiospodeserbaixadodoendereowww.nagios.org/docs.UmaversotraduzidadoManualpodeserencontradaem
http://www2.dcc.ufmg.br/~leoh/nagios.Ostrsitensacima(1.1,1.2e1.3),porexemplo,foramextradosdessaltima.Destarte,meus
sincerosagradecimentosaLeonardoHenriqueMachado,mantenedordosite,pelotimotrabalhorealizado.Aleituradeumdesses
documentos,previamenteinstalaodoNagios,altamenterecomendvel.
OSistemaOperacionalutilizadocomobaseparaaelaboraodesseguiafoioRedHat9comkernellinux2.4.22.
NagioseologotipoNagiossomarcasregistradasdeEthanGalstad.Todosasdemaismarcas,servicemarks,marcasregistradas,e
servicemarksregistradosdeveroserdepropriedadedeseu(s)respectivo(s)dono(s).

2 INSTALAO
2.1 Adio do usurio/grupo 'nagios' ao Sistema
#addusernagios

2.2 Download, Descompactao e Instalao do Nagios e dos plugins


#mkdir/home/nagios/tmp
>FazerodownloaddoNagiosedosplugins(www.nagios.org/download)paraodiretrioacima.

#cd/home/nagios/tmp
#lsa

.
nagios2.0.tar.gz
..
nagiosplugins1.4.2.tar.gz

>Descompactarosarquivos:
#tarxvfz<nome_do_arquivo_do_Nagios>(ex.:#tarxvfznagios2.0.tar.gz)
#tarxvfz<nome_do_arquivo_dos_plugins>(ex.:#tarxvfznagiosplugins1.4.2.tar.gz)
>EntrarnodiretriodoNagioscriado(ex.:#cd/home/nagios/tmp/nagios2.0).
>RodaroscriptdeconfiguraodoNagios(Paraverasopes:#./configurehelp):
prefix:diretriodeinstalaodoNagios;
withnagiosuser:usuriopadro;
withnagiosgroup:grupopadro;
withhtmurl:endereowebdeacessoaoNagios(padro:http://<endereo_local>/nagios);
withcgiurl:endereowebdosCGIs(padro:http://<endereo_local>/nagios/cgibin).
#./configureprefix=/usr/local/nagioswithnagiosuser=nagioswithnagiosgroup=nagioswithhtmurl=/nagioswith
cgiurl=/nagios/cgibin

***Configurationsummaryfornagios2.002072006***:

GeneralOptions:

Nagiosexecutable:nagios
Nagiosuser/group:nagios,nagios
Commanduser/group:nagios,nagios
EmbeddedPerl:no
EventBroker:yes
Install${prefix}:/usr/local/nagios
Lockfile:${prefix}/var/nagios.lock
Initdirectory:/etc/rc.d/init.d
HostOS:linuxgnu

WebInterfaceOptions:

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

#makeall
#makeinstall
#makeinstallinit
#makeinstallcommandmode
#makeinstallconfig

(Compilaosfontes)
(Instalaoprogramaprincipal,asCGIseosarquivosHTML)
(Instalaoscriptdeinicializaoem/etc/rc.d/init.d)
(Instalaeconfigurapermissesparaodiretrioqueconteroarquivodecomandosexternos)
(Instalaarquivosdeconfiguraodeexemplo[*SAMPLE*]em/usr/local/nagios/etc)

>Irparaodiretrioondeforambaixadososplugins:(ex.:#cd/home/nagios/tmp/nagiosplugins1.4.2)

OBS.:Parapoderemserusados,algunsdospluginsprecisamquesetenhainstaladosnocomputadorcertosprogramase/oubibliotecas
especficos.Nocasodainexistnciadessesltimosnamquina,ospluginsdelesdependentesgeralmentenosocompilados.Destarte,
antesdeseiniciarainstalaodospluginsrecomendvelaleituradoarquivoREQUIREMENTS.

>Rodaroscriptdeconfiguraodosplugins(Paraverasopes:#./configurehelp):
#./configureprefix=/usr/local/nagioswithnagiosuser=nagioswithnagiosgroup=nagios
#makeall
#makeinstall

OBS.:Casoseexperimentealgumproblemarelativoaacesso,podesernecessrioalteraralgumaspermisses.
>DiretriodeinstalaodoNagios(/usr/local/nagios):#chownnagios:nagios/usr/local/nagios

>Diretriodeinstalaodosplugins(/usr/local/nagios/libexec):#chownnagios:nagios/usr/local/nagios/libexec
>Arquivosdosplugins:#chownnagios:nagios/usr/local/nagios/libexec/*

2.3 Configurao da Interface Web Apache


>Localizaroarquivohttpd.conf:
#find/namehttpd.conf(ex.:/etc/httpd/conf/httpd.conf)
#vi/.../httpd.conf(colocarocaminhocorreto)
>Editaroarquivo,adicionandoaslinhasabaixo:
###############################################################################
#HTML(http://localhost/nagios)ANDCGIAPACHEAUTHENTICATION
###############################################################################
ScriptAlias/nagios/cgibin"/usr/local/nagios/sbin"
<Directory"/usr/local/nagios/sbin">
AllowOverrideAuthConfig
OptionsExecCGI
Orderallow,deny
Allowfromall
AuthName"NagiosAccess"
AuthTypeBasic
AuthUserFile/usr/local/nagios/etc/htpasswd.users
requirevaliduser
</Directory>
Alias/nagios"/usr/local/nagios/share"
<Directory"/usr/local/nagios/share">
AllowOverrideAuthConfig
OptionsNone
Orderallow,deny
Allowfromall
AuthName"NagiosAccess"
AuthTypeBasic
AuthUserFile/usr/local/nagios/etc/htpasswd.users
requirevaliduser
</Directory>
###############################################################################
>CriaroarquivocomousurioesenhadeacessoaoNagios:
#htpasswdc/usr/local/nagios/etc/htpasswd.usersusuario1
>ReiniciaroApache:
#/usr/sbin/httpdkrestart
>Apsisso,jdeveserpossvelvisualizarainterfacewebdoNagiosapartirdoendereohttp://localhost/nagios

nonavegador

.
Entretanto,asCGIsnoforneceroinformaoalguma(aindanecessrioconfigurarcorretamenteoNagios).

OBS.:Casoseexperimentealgumproblemarelativoaacesso,podesernecessrioalteraraspermissesdoarquivohtpasswd.users:
#chownapache:apache/usr/local/nagios/etc/htpasswd.users(verificarousurioegrupodoApache).

2.4 Configurao do Nagios


>Fazerbackupdosarquivosdeexemplo:
#mkdir/usr/local/nagios/etc/sample
#cp/usr/local/nagios/etc/*.cfgsample/usr/local/nagios/etc/sample
>Renomearosarquivos.cfgsamplepara.cfg:
#foriin*cfgsample;domv$i`echo$i|sedes/cfgsample/cfg/`;done;

OBS.:Seocomandoacimanofuncionar,renomearumporum(ex.:#mvcgi.cfgsamplecgi.cfg).

2.4.1 Configurao utilizando-se o arquivo minimal.cfg


>Descriodosarquivosdeconfiguraoutilizados:
nagios.cfg:arquivoprincipaldeconfiguraodoNagios;
cgi.cfg:arquivodeconfiguraodasCGIs;
minimal.cfg:arquivodeconfiguraominimalstico(utilizadosobretudoparafinsdetestedainstalaodoNagios);
resource.cfg:arquivocontendomacrosdefinidaspelousurio.
>Paratestar,primeiroediteoarquivonagios.cfg(#vinagios.cfg),comentandoaslinhasabaixo:
cfg_file=/usr/local/nagios/etc/checkcommands.cfg >#cfg_file=/usr/local/nagios/etc/checkcommands.cfg
cfg_file=/usr/local/nagios/etc/misccommands.cfg >#cfg_file=/usr/local/nagios/etc/misccommands.cfg
>Editeoarquivominimal.cfg(contacts,hosts,services)paraqueestefiquedeacordocomasconfiguraesdesejadas:
#viminimal.cfg

OBS.:Adescrioeumdetalhamentomaiordosdiferentesitensdessearquivo(TimePeriods,Commands,Contacts...)podemser
encontradosnasseesObjectDefinitionseTemplateBasedObjectConfigurationdoManualdoNagios.

2.4.2 Configurao utilizando-se arquivos especficos para cada item


>Aoinvsdeseutilizarumnicoeextensoarquivodeconfigurao(minimal.cfg),possvelsepararessearquivoemumasriede
arquivosdistintos,cadaumcontendoasinformaesrelativasaapenasumitemespecficodeconfigurao.
>Descriodosarquivosdeconfiguraoutilizados:
nagios.cfg,cgi.cfg,resource.cfg:descritosnoitemanterior;
timeperiods.cfg:definiesdehorriosconsideradosvlidosparaarealizaodechecagenseenviodenotificaes;
checkcommands.cfg:definiesdoscomandosdechecagemdehostseservios;
misccommands.cfg:definiesdoscomandosdenotificaoedeprocessamentodedadosdeperformance;
contacts.cfg:indivduosque,possivelmente,deverosernotificadosnocasodeproblemasnarede;
contactgroups.cfg:usadoparajuntaroscontatosemgrupos,parafinsdeenviodealertas/notificaes;
hosts.cfg:defineservidores,estaesdetrabalhoedemaisdispositivosdaredeemgeral;
hostgroups.cfg:usadoparajuntaroshostsemgrupos,parafinsdesuaexibionasCGIs;
services.cfg:identificamosserviosqueestosendomonitoradosnosdiferenteshosts;
servicegroups.cfg:usadoparajuntarosserviosemgrupos,parafinsdesuaexibionasCGIs;
servicedependencies.cfg:permiteasupressodechecagensenotificaesparaumservio,combasenostatusdeoutro(s);
serviceescalations.cfg:permiteoescalonamentodenotificaesparaumdeterminadoservio;
hostdependencies.cfg:permiteasupressodechecagensenotificaesparaumhost,combasenostatusdeoutro(s);
hostescalations.cfg:permiteoescalonamentodenotificaesparaumdeterminadohost;
ext_host_info.cfg:usadoparaincrementarasadadasCGIsstatus,statusmap,statuswrleextinfo;
ext_service_info.cfg:usadoparaincrementarasadadasCGIsstatuseextinfo.

OBS.:Paraoscasosemqueosarquivosdescritosnoexistirempreviamente(timeperiods.cfg,hosts.cfg,hostgroups.cfg...),elesdevero
sercriados(ex.:#vihosts.cfg),copiandoseecolandoseaparterelativaaosmesmosconstantenoarquivominimal.cfg.

>Percebaquenemtodososarquivosdescritossoestritamentenecessrios.Entretanto,elespoderoserusadosnoscasosemquese
desejerealizarumaconfiguraomaisavanadadoNagios(fazendoseusodedependnciaseescalonamentos,porexemplo).Nonosso
caso,noutilizaremosnenhumdosarquivosapartirdeservicegroups.cfg,inclusive.Emtodocaso,conformejditoanteriormente,
possvelencontraradescrioeumdetalhamentomaiordosdiferentesitensqueirocomporosarquivosacimanasseesObject
DefinitionseTemplateBasedObjectConfigurationdoManualdoNagios.
2.4.2.1 nagios.cfg
#vinagios.cfg
>Comentaralinhareferenteaoarquivodeconfiguraominimalstico(minimal.cfg):
cfg_file=/usr/local/nagios/etc/minimal.cfg>#cfg_file=/usr/local/nagios/etc/minimal.cfg

>Descomentaraslinhasreferentesaosarquivosdeconfiguraoqueseroutilizados:
#cfg_file=/usr/local/nagios/etc/timeperiods.cfg
>cfg_file=/usr/local/nagios/etc/timeperiods.cfg
#cfg_file=/usr/local/nagios/etc/checkcommands.cfg >cfg_file=/usr/local/nagios/etc/checkcommands.cfg
#cfg_file=/usr/local/nagios/etc/misccommands.cfg >cfg_file=/usr/local/nagios/etc/misccommands.cfg
#cfg_file=/usr/local/nagios/etc/contacts.cfg
>cfg_file=/usr/local/nagios/etc/contacts.cfg
#cfg_file=/usr/local/nagios/etc/contactgroups.cfg
>cfg_file=/usr/local/nagios/etc/contactgroups.cfg
#cfg_file=/usr/local/nagios/etc/hosts.cfg
>cfg_file=/usr/local/nagios/etc/hosts.cfg
#cfg_file=/usr/local/nagios/etc/hostgroups.cfg
>cfg_file=/usr/local/nagios/etc/hostgroups.cfg
#cfg_file=/usr/local/nagios/etc/services.cfg
>cfg_file=/usr/local/nagios/etc/services.cfg
>Alteraraopodeformataodadata(DATEFORMATOPTION)paraopadroeuropeu:
date_format=us >date_format=euro

2.4.2.2 cgi.cfg
#vicgi.cfg
>Realizarasalteraesabaixo(edescomentar,seforocaso):
use_authentication=1
authorized_for_system_information=usuario1
authorized_for_configuration_information=usuario1
authorized_for_systemcommands=usuario1
authorized_for_all_services=usuario1
authorized_for_all_hosts=usuario1
authorized_for_all_service_commands=usuario1
authorized_for_all_host_commands=usuario1

2.4.2.3 timeperiods.cfg
#vitimeperiods.cfg
>Realizarasalteraesabaixo:
###############################################################################
#TIMEPERIODS
###############################################################################

definetimeperiod{
timeperiod_name
24x7
alias
24HoursADay,7DaysAWeek
sunday
00:0024:00
monday
00:0024:00
tuesday
00:0024:00
wednesday
00:0024:00
thursday
00:0024:00
friday
00:0024:00
saturday
00:0024:00
}

2.4.2.4 checkcommands.cfg
#vicheckcommands.cfg
>Realizaraseguintealteraonadefiniodocomando'check_local_procs':
$USER1$/check_procsw$ARG1$c$ARG2$s$ARG3$>$USER1$/check_procsw$ARG1$c$ARG2$
2.4.2.5 contacts.cfg
#vicontacts.cfg
>Realizarasalteraesabaixo:

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

definecontact{
contact_name
usuario1
alias
Usuario1
service_notification_period
24x7
host_notification_period
24x7
service_notification_options
w,u,c,r
host_notification_options
d,u,r
service_notification_commands notifybyemail
host_notification_commands
hostnotifybyemail
email
email@localhost.localdomain#Enderecodeemaildousuario1.
}

2.4.2.6 contactgroups.cfg
#vicontactgroups.cfg
>Realizarasalteraesabaixo:
###############################################################################
#CONTACTGROUPS
###############################################################################

definecontactgroup{
contactgroup_name
admins
alias
AdministradoresdoNagios
members
usuario1
}

2.4.2.7 hosts.cfg
#vihosts.cfg
>Realizarasalteraesabaixo:
###############################################################################
#HOSTS
###############################################################################

#Template!
definehost{
name
generichost;Thenameofthishosttemplate
notifications_enabled
1;Hostnotificationsareenabled
event_handler_enabled
1;Hosteventhandlerisenabled
flap_detection_enabled
1;Flapdetectionisenabled
failure_prediction_enabled
1;Failurepredictionisenabled
process_perf_data
1;Processperformancedata
retain_status_information
1;Retainstatusinformationacrossprogramrestarts
retain_nonstatus_information
1;Retainnonstatusinformationacrossprogramrestarts
register
0;DONTREGISTERITSNOTAREALHOST,JUSTATEMPLATE!
}
#Localhost
definehost{
use
host_name
alias
address
check_command

generichost;Nameofhosttemplatetouse
localhost
localhost
127.0.0.1
checkhostalive

max_check_attempts
notification_interval
notification_period
notification_options
contact_groups
}

10
120
24x7
d,r
admins

2.4.2.8 hostgroups.cfg
#vihostgroups.cfg
>Realizarasalteraesabaixo:
###############################################################################
#HOSTGROUPS
###############################################################################

definehostgroup{
hostgroup_name
servers
alias
Servidores
members
localhost
}

2.4.2.9 services.cfg
#viservices.cfg
>Realizarasalteraesabaixo:
###############################################################################
#
#SERVICES
#
###############################################################################

###############################################################################
#LOCALHOSTNAGIOS
###############################################################################
#Template!
defineservice{
name
active_checks_enabled
passive_checks_enabled
parallelize_check
obsess_over_service
check_freshness
notifications_enabled
event_handler_enabled
flap_detection_enabled
failure_prediction_enabled
process_perf_data
retain_status_information
retain_nonstatus_information
register
}

genericservice;Thenameofthisservicetemplate
1;Activeservicechecksareenabled
1;Passiveservicechecksareenabled/accepted
1;Activeservicechecksshouldbeparallelized
#(disablingthiscanleadtomajorperformanceproblems)
1;Weshouldobsessoverthisservice(ifnecessary)
0;DefaultistoNOTcheckservice'freshness'
1;Servicenotificationsareenabled
1;Serviceeventhandlerisenabled
1;Flapdetectionisenabled
1;Failurepredictionisenabled
1;Processperformancedata
1;Retainstatusinformationacrossprogramrestarts
1;Retainnonstatusinformationacrossprogramrestarts
0;DONTREGISTERITSNOTAREALSERVICE,JUSTATEMPLATE!

#Serviodechecagemdoespaoemdisconapartiorootdamquinalocal.
#Warningse<20%livre,Criticalse<10%livre.
defineservice{
use
genericservice;Nameofservicetemplatetouse

host_name
service_description
is_volatile
check_period
max_check_attempts
normal_check_interval
retry_check_interval
contact_groups
notification_options
notification_interval
notification_period
check_command
}

localhost
RootPartition
0
24x7
4
5
1
admins
w,u,c,r
960
24x7
check_local_disk!20%!10%!/

#Serviodechecagemdonmerodeusurioscorrentementelogadosnamquinalocal.
#Warningse>20usurios,Criticalse>50usurios.
defineservice{
use
genericservice;Nameofservicetemplatetouse
host_name
localhost
service_description
CurrentUsers
is_volatile
0
check_period
24x7
max_check_attempts
4
normal_check_interval
5
retry_check_interval
1
contact_groups
admins
notification_options
w,u,c,r
notification_interval
960
notification_period
24x7
check_command
check_local_users!20!50
}
#Serviodechecagemdonmerodeprocessoscorrentementerodandonamquinalocal.
#Warningse>250processos,Criticalse>400processos.
defineservice{
use
genericservice;Nameofservicetemplatetouse
host_name
localhost
service_description
TotalProcesses
is_volatile
0
check_period
24x7
max_check_attempts
4
normal_check_interval
5
retry_check_interval
1
contact_groups
admins
notification_options
w,u,c,r
notification_interval
960
notification_period
24x7
check_command
check_local_procs!250!400
}
#Serviodechecagemdacarganamquinalocal.
defineservice{
use
genericservice;Nameofservicetemplatetouse
host_name
localhost
service_description
CurrentLoad
is_volatile
0
check_period
24x7
max_check_attempts
4
normal_check_interval
5
retry_check_interval
1
contact_groups
admins
notification_options
w,u,c,r

notification_interval
notification_period
check_command
}

960
24x7
check_local_load!5.0,4.0,3.0!10.0,6.0,4.0

#Serviode"ping"damquinalocal
defineservice{
use
genericservice;Nameofservicetemplatetouse
host_name
localhost
service_description
PING
is_volatile
0
check_period
24x7
max_check_attempts
4
normal_check_interval
5
retry_check_interval
1
contact_groups
admins
notification_options
w,u,c,r
notification_interval
960
notification_period
24x7
check_command
check_ping!100.0,20%!500.0,60%
}

OBS.:Paraseobterumadescriodoquerealizam,exemplos,bemcomodetalhesrelativosaousoesvriasopesdeparmetros
aceitasporcadaumdosplugins,bastadarocomando'#./nome_do_pluginh[elp]'nodiretrioemqueestesestejam(ex.:
/usr/local/nagios/libexec).

>Alterarapermissodosarquivoscriados:
#chownnagios:nagios/usr/local/nagios/etc/*.cfg

2.5 Checagem da Configurao e Inicializao do Nagios


>ParachecarseesttudoOK:
#/usr/local/nagios/bin/nagiosv/usr/local/nagios/etc/nagios.cfg

OBS.:Casohajaerrodeconfigurao,ocomandoacimaapontarorespectivoarquivoelinhaemqueesseseencontra.Nessecaso,basta
ircorrigindoseqencialmenteosmesmos,executandoseomesmocomandoatquenenhumerrosejamaisindicado.

>Parainiciar/parar/reiniciaroNagios:
#/etc/rc.d/init.d/nagiosstart[stop][restart]

OBS.:Casoseexperimentealgumtipodeproblemaoucomportamentoinesperado,convmverificarse:
i)aspermissesparaousurioegrupo'nagios'foramadequadamentealteradas(observaofinaldoitem2.2);
ii)oApacheestcorretamenteconfiguradoerodando(referirseaoitem2.3);
ii)osarquivosdeconfigurao(/usr/local/nagios/etc/*.cfg)forameditadoscorretamente(referirseaoitem2.4).

>ApsseiniciaroNagios,possvelconferirseesteestmesmorodando(everoseuPID)apartirdocomando:
#psaux|grepnagios

2.6 Monitoramento da Rede


>AgoraquetantooApachequantooNagiosjestoconfiguradoserodando,entrenovamentecomoendereohttp://localhost/nagios
nonavegadoreconfiraoresultadodasconfiguraesefetuadas(Fig.01).

Figu
ra01DetalhedomonitoramentodohostlocalobtidoapartirdaguiaServiceDetailnainterfacewebdoNagios.

>ParahabilitaroenviodecomandosexternosaoNagios,porexemplo,pormeiodainterfaceweb:
#vi/usr/local/nagios/etc/nagios.cfg>check_external_commands=1
#chownRnagios:apache/usr/local/nagios/var/rw

2.7 Execuo de Plugins em Hosts Remotos Addon NRPE


>Parapermitiraexecuodechecagensativasemhostsremotos,necessriaainstalaodopluginNRPE(check_nrpe)no
computadorqueirrodaroNagios,bemcomodeclientesNRPE(daemons)noscomputadoresaseremmonitoradosremotamente.

2.7.1 Adio do usurio/grupo 'nagios' aos Hosts Remotos


2.7.1.1 Host Remoto Linux
#addusernagios

2.7.1.2 Host Remoto FreeBSD


#pwgroupaddnagios
#addusernagios

Username:nagios
Password:*****
FullName:Nagios
Uid:10222
Class:
Groups:nagios
Home:/home/nagios
Shell:/usr/local/bin/bash
Locked:no
OK?(yes/no):yes
adduser:INFO:Successfullyadded(nagios)totheuserdatabase.

2.7.2 Download,
Download, Instalao e Configurao do NRPE nos Hosts Remotos
2.7.2.1 Host Remoto Linux
>FazerodownloaddoaddonNRPE(ex.:nrpe2.3.tar.gz,www.nagios.org/download)paraodiretrio/home/nagios/tmp.
#cd/home/nagios/tmp
#tarxvfz<nome_do_arquivo_do_NRPE>(ex.:#tarxvfznrpe2.3.tar.gz)
>EntrarnodiretriodoNRPEcriado(ex.:#cd/home/nagios/tmp/nrpe2.3).
#./configure


***Configurationsummaryfornrpe2.301232006***:

GeneralOptions:

NRPEport:5666
NRPEuser:nagios
NRPEgroup:nagios

#makeall
>Realizar,nohostremoto,oprocedimentodedownloadeinstalaodosplugins,conformedescritonoitem2.2,tomandoseapenaso
cuidadodealteraralinhaabaixoadequadamente:
#./configureprefix=/home/nagioswithnagiosuser=nagioswithnagiosgroup=nagios

2.7.2.2 Host Remoto FreeBSD


>InstalaroaddonNRPEapartirdomecanismoportsdoFreeBSD:
#cd/usr/ports
#makesearchname=nrpe

Port:nrpe22.0_1
Info:NagiosRemotePluginExecutor
Path:/usr/ports/netmgmt/nrpe2
Maint:paul@nerdlabs.com
Bdeps:perl5.8.7
Rdeps:nagiosplugins1.4_3,1perl5.8.7
WWW:http://www.nagios.org/

#cd/usr/ports/netmgmt/nrpe2(#cd<Path>)
#makeall
>MarcarasopesSSL(SSLsupport)eARGS(Enablecommandarguments)edarOK.

***Configurationsummaryfornrpe2.009082003***:

GeneralOptions:

NRPEport:5666
NRPEuser:nagios
NRPEgroup:nagios
(...)
***Compilefinished***
(...)

OBS.:NocasodoFreeBSD,ainstalaodoaddonNRPEpeloportscuidaautomaticamente,tambm,dainstalaodosplugins.

2.7.2.3 Ambos Linux e FreeBSD

OBS.:ApesardenosernecessrioinstalaroNagios,tambm,emcadaumdoshostsremotos,preciso,sim,instalarnestes,conforme
explicitadoacima,osplugins,demodoqueesteshostssejamcapazesdeefetuar,entreoutrascoisas,certaschecagensderecursoslocais
como,porexemplo,averificaodoespaoemdisco,apartirdainteraocomoaddonNRPE.
OBS2.:Seossistemasoperacionaisforemcompatveis,podeservivel(e,dependendodocaso,menostrabalhoso)realizarseasimples
cpiadodiretriodospluginsdamquinaondefoioriginalmenteinstaladooNagios(/usr/local/nagios/libexec)para/home/nagiosno
hostremoto,como,porexemplo,nocasoemquesejapossvelfazerumacessoremotodeumamquinaparaoutra
(ex.:#scp/usr/local/nagios/libexec[r]<IP_do_host_remoto>:/home/nagios).


>EditaroarquivodeconfiguraodoNRPE,nrpe.cfg(ex.:#vi/home/nagios/tmp/nrpe2.3/sampleconfig/nrpe.cfg),adicionandoa
seguintelinhadedefiniodecomandoemCOMMANDDEFINITIONS:
command[check_local_disk]=/home/nagios/libexec/check_diskw20%c10%p/
>Adicionaraseguintelinhanoarquivo/etc/services:
nrpe5666/tcp#NRPE(Nagios)
>Adicionarentradaaoarquivo/etc/hosts.allowparahabilitaroacessodohostqueirrodaroNagiosaoservionrpe:
nrpe:<IP_do_host_do_Nagios>:allow

2.7.3 Configurao do NRPE no Host Local (Nagios)


>Realizar,nohostlocal(Nagios),oprocedimentodedownloadeinstalaodoaddonNRPE,conformedescritonoitem2.7.2.
>Copiaroarquivocheck_nrpegeradoparaodiretriodospluginsdoNagios:
#cp/home/nagios/tmp/nrpe2.3/src/check_nrpe/usr/local/nagios/libexec

OBS.:Oprocedimentoacimasefaznecessriotosomentepelanecessidadedeseternohostlocal(Nagios)oplugincheck_nrpe,gerado
comainstalaodoaddonNRPE.Seossistemasoperacionaisforemcompatveis,podeservivel(e,dependendodocaso,menos
trabalhoso)realizarseasimplescpiadessearquivodohostremotonoqualoaddonjfoiinstalado(item2.7.2)paraohostlocal(que
rodaroNagios),como,porexemplo,nocasoemquesejapossvelacessarremotamenteumamquinaapartirdaoutra
(ex.:#scp/home/nagios/tmp/nrpe2.3/src/check_nrpe<IP_do_host_do_Nagios>:/usr/local/nagios/libexec).
OBS2.:ParaqueoaddonNRPEfuncionecorretamente,precisoatentarparacertosdetalhescomo,porexemplo,utilizaramesma
versododaemonNRPE(hostremoto)edoplugincheck_nrpe(hostdoNagios),habilitar/desabilitaroSSLemtodososhosts,reveras
permissesdealgunsarquivos(ex.:nrpe.cfg),permitir,no(s)host(s)remoto(s),oacessoaoendereoIPdamquinaquerodaroNagios
(arquivohosts.allow,linhaonly_fromdoarquivodeconfiguraodoxinetd).Paramaioresinformaesarespeitodospossveiserros
quepodemaparecer,favorconsultaroFAQdoNagios(www.nagios.org/faqs).

>Inserir,aofinaldoarquivodeconfiguraodecomandosdoNagios(#vi/usr/local/nagios/etc/checkcommands.cfg):
################################################################################
#NRPECOMMAND
################################################################################

#'check_nrpe'commanddefinition
definecommand{
command_name
check_nrpe
command_line
$USER1$/check_nrpeH$HOSTADDRESS$c$ARG1$
}
>
Asdefiniesdeserviosquefaamusodo

plugin

/daemonNRPEparaobterseusresultadosdeveroseguiromodeloabaixo:

defineservice{
use
genericservice;Nameofservicetemplatetouse
host_name
algum_host_remoto
service_description
algum_servio_remoto
...etc...
check_command
check_nrpe!yourcommand
}

OBS.:yourcommandonomedeumcomandodefinidonoarquivonrpe.cfgdohostremoto,aexemplodoquefoiestabelecidonoitem
2.7.1(command[check_local_disk]=/home/nagios/libexec/check_diskw20%c10%p/).

>Exemplo:Adicionaraofinaldoarquivoservices.cfg
###############################################################################
#HOSTREMOTOALGUM_HOST_REMOTO
###############################################################################
#Serviodechecagemdoespaoemdisconapartiorootdohostremoto.
#Warningse<20%livre,Criticalse<10%livre.

defineservice{
use
host_name
service_description
is_volatile
check_period
max_check_attempts
normal_check_interval
retry_check_interval
contact_groups
notification_options
notification_interval
notification_period
check_command
}

genericservice;Nameofservicetemplatetouse
host_remoto
ParticaoRoot
0
24x7
4
5
1
admins
w,u,c,r
960
24x7
check_nrpe!check_local_disk

#Serviode"ping
"dehostremoto

defineservice{
use
genericservice;Nameofservicetemplatetouse
host_name
host_remoto
service_description
PING
is_volatile
0
check_period
24x7
max_check_attempts
4
normal_check_interval
5
retry_check_interval
1
contact_groups
admins
notification_options
w,u,c,r
notification_interval
960
notification_period
24x7
check_command
check_ping!100.0,20%!500.0,60%
}

OBS.:Percebacomo,nocasodoprimeiroserviodefinidoacima(PartioRoot),sefezusodopluginNRPE(check_nrpechamandoo
comandocheck_local_disk,definidonoarquivonrpe.cfgdohostremoto),porsetratardachecagemdeumrecursolocaldamquina
remota(espaoemdisco),noverificveldiretamentepelarede.Jachecagemdefinidanosegundoservio(PING),poroutrolado,
possveldeserrealizadadiretamentepelarede,nonecessitando,assim,recorreraopluginNRPE.

>ReiniciaroNagios:
#/etc/rc.d/init.d/nagiosrestart

2.7.4 Inicializao do NRPE nos Hosts Remotos


>>>PARACADAUMDOSHOSTSREMOTOSASEREMMONITORADOS,realizarospassosaseguir:
#/home/nagios/tmp/nrpe2.3/src/nrpec/home/nagios/tmp/nrpe2.3/sampleconfig/nrpe.cfgd
>ApsseiniciaroNRPE,possvelconferirseesteestmesmorodando(everoseuPID)apartirdocomando:
#psaux|grepnrpe
>Apartirdessemomento,oNagiosjdevesercapazdemonitorar,tambm,ohostremoto(Fig.02).

Figu
ra02DetalhedomonitoramentodoshostslocaleremotoobtidoapartirdaguiaServiceDetailnainterfacewebdoNagios.

2.8 Inicializao Automtica do Sistema de Monitoramento


2.8.1 Iniciando o Nagios com o Boot do Sistema (Host
(Host Local)
>Verificarem/etc/inittaborunlevelpadro(06)emqueosistemaestsendoiniciado(procurarpelalinha'initdefault'):
#more/etc/inittab(ex.:id:3:initdefault:)
>Listarosarquivosdodiretriodeinicializaocorrespondenteaorunlevelpadroencontradoacima:
#lsl/etc/rc.d/rc?.d(ex.:lsl/etc/rc.d/rc3.d)

lrwxrwxrwx1rootroot14Jun132005K05innd>../init.d/innd
lrwxrwxrwx1rootroot19Jun132005K05saslauthd>../init.d/saslauthd
lrwxrwxrwx1rootroot17Jun132005K09privoxy>../init.d/privoxy
lrwxrwxrwx1rootroot16Jun132005K10psacct>../init.d/psacct
(...)
lrwxrwxrwx1rootroot15Jun132005S97rhnsd>../init.d/rhnsd
lrwxrwxrwx1rootroot11Jun132005S99local>../rc.local
lrwxrwxrwx1rootroot19Jun132005S99mdmonitor>../init.d/mdmonitor

>Comosepodeperceber,nenhumdosscriptsqueefetivamenteiniciamouparamosserviosemquestoestorealmentelocalizados
nessediretrio(nocaso,/etc/rc.d/rc3.d).Oquesetemaquisoapenaslinkssimblicos(softlinks)paraosmesmos,osquaisselocalizam,
emefeito,nodiretrio/etc/rc.d/init.d.Issofeitoparaquesejapossvelreconfigurarainicializaodosdiferentesrunlevelspormeioda
criao,modificaoedeleodelinkssimblicosapenas,sem,contudo,afetarosprpriosscriptsporelesreferenciados.Osnomesdos
linkspodemseriniciadosporKouporS,seguidosdeumnmero.OslinksKreferemseaprocessosqueserointerrompidos(killed)na
inicializaodorunlevel(execuodocomando'/etc/rc.d/init.d/<processo>stop'),aopassoqueoslinksSrepresentamprocessosque
sero,porsuavez,iniciados(started;execuode'/etc/rc.d/init.d/<processo>start').Oprocedimentodeinterrupodeprocessos(links
K)ocorreprimeiroqueodeinicializao(linksS),emambososcasosobedecendoaordemnumricarespectiva.Nocasodeprocessos
comamesmanumerao,segueseaordemalfabticadonome.
>Criar,nodiretriodeinicializaodorunlevelpadro(ex.:/etc/rc.d/rc3.d),umlinksimblicoparaolanamentodoNagios
(/etc/rc.d/init.d/nagios)comobootdosistema(ex.:#lns/etc/rc.d/init.d/nagios/etc/rc.d/rc3.d/S99nagios).

OBS.:Opcionalmente,realizaromesmoprocedimentoparaolanamentoautomticodoserviohttpd(Apache)nainicializao:
>Criar,nodiretriodeinicializaodorunlevelpadro(ex.:/etc/rc.d/rc3.d),umlinksimblicoparaolanamentodoserviohttpd
(/etc/rc.d/init.d/httpd)comobootdosistema(ex.:#lns/etc/rc.d/init.d/httpd/etc/rc.d/rc3.d/S99httpd).

2.8.2 Iniciando o NRPE com o Boot do Sistema (Hosts


(Hosts Remotos)
2.8.2.1 Mtodo 1 INETD ou XINETD
>>>PARACADAUMDOSHOSTS
REMOTOSASEREMMONITORADOS,realizarospassosaseguir:
>>>PARACADAUMDOSHOSTSREMOTOSASEREMMONITORADOS,realizarospassosaseguir:
>AdicionarentradasparaodaemonNRPEaoarquivodeconfigurao,dependendodosistema,doinetdouxinetd:
a)INETD(/etc/inetd.confou/etc/inet/inetd.conf)
i)WITHtcpwrappers:
nrpe stream tcp
nowait
<user>
/.../tcpd<nrpebin>c<nrpecfg>inetd

(obs.:/.../tcpd=/usr/sbin/tcpd,/usr/libexec/tcpdou/usr/etc/tcpd,porexemplo,conformeocaso)
ii)WITHOUTtcpwrappers: nrpe stream tcp
nowait
<user>
<nrpebin>c<nrpecfg>inetd
b)XINETD:Criarumarquivochamado'nrpe'nodiretrio/etc/xinetd.dcontendo:
#default:on
#description:NRPE
servicenrpe
{
flags
=REUSE
socket_type
=stream
wait
=no
user
=<user>
server
=<nrpebin>
server_args
=c<nrpecfg>inetd
log_on_failure +=USERID
disable
=no
only_from
=<ipaddress1><ipaddress2>...
}

OBS.: <user>:usurioemnomedoqualoservidornrpedeverodar;
<nrpebin>:caminhodobinrionrpenosistema(ex.:/home/nagios/tmp/nrpe2.3/src/nrpe);
<nrpecfg>:caminhodoarquivodeconfiguraonrpenosistema(ex.:/home/nagios/tmp/nrpe2.3/sampleconfig/nrpe.cfg);
<ipaddress>:endereosIPdoshostspermitidosaseconectarcomodaemonNRPE.Funcionaapenascasooxinetdtenhasido
compiladocomsuporteatcpwrappers.

>Reiniciaroinetdouxinetd,conformesejaocaso:
#/etc/rc.d/inetd[xinetd]restart

2.8.2.2 Mtodo 2 Edio de Arquivos de Inicializao


2.8.2.2.1 Host Remoto Linux (Arquivo rc.local)

>>>PARACADAUMDOSHOSTSREMOTOSLINUXASEREMMONITORADOS,realizaroprocedimentoaseguir:
>Editaroarquivorc.local(#vi/etc/rc.d/rc.local),adicionandoumalinhareferentechamadadeexecuodoclienteNRPE(ex.:
/home/nagios/tmp/nrpe2.3/src/nrpec/home/nagios/tmp/nrpe2.3/sampleconfig/nrpe.cfgd).

2.8.2.2.2 Host Remoto FreeBSD (Arquivo rc.conf)

>>>PARACADAUMDOSHOSTSREMOTOSFREEBSDASEREMMONITORADOS,realizaroprocedimentoaseguir:
>CopiaroscriptdeinicializaodoNRPE(ex.:/usr/ports/netmgmt/nrpe2/work/nrpe2.sh)para/usr/local/etc/rc.d:
#cp/usr/ports/netmgmt/nrpe2/work/nrpe2.sh/usr/local/etc/rc.d
>Editaroarquivorc.conf(#vi/etc/rc.conf),adicionando,deformadiferentedaacima,areferidalinhadechamadaautomticade
execuodoNRPE(nrpe2_enable=YES).