Nagios Module 1

Embed Size (px)

Citation preview

  • 8/10/2019 Nagios Module 1

    1/123

    GnuGroup InternationalGnuGrou

    p International

    NagiosN

    agios

    IT infrastructure monitoring toolIT infrastructure monitorin

    g tool

    ILGILGInsight GNU/Linux GroupIns

    ight GNU/Linux Group

    Reinventing the way you,Reinventing the way you,Think,Think,Learn,Learn,WorkWork

  • 8/10/2019 Nagios Module 1

    2/123

    www.gnugroup.org 2

    NAGIOS

    MODULE - 1

  • 8/10/2019 Nagios Module 1

    3/123

    www.gnugroup.org 3

    Index of module - 1

    Introduction

    History of Naios

    System !e"uirements

    #rere"uisites Licensin

    Do$nloadin

    Ad%ice for &einners

    'uic(start installation

    Naios Arc)itecture #luins

    !emote MonitorinMec)anisms

    Monitorin *indo$s

    Monitor !emote Linux Host

    Monitor Net$or( S$itc)

    +onfiuration o%er%ie$

    O,ect confiuration o%er%ie$ O,ect Definitions

    !unnin Naios

    Notifications

    Host+)ec(s

    Ser%ice +)ec( Acti%e +)ec(

    #assi%e +)ec(

    States ty.es

  • 8/10/2019 Nagios Module 1

    4/123

    www.gnugroup.org 4

    Introduction

    What is Nagios Core?

    Nagios CoreTM is an Open Source system and network monitoring

    application.

    It watches hosts and services that you specify, alerting youwhen things go bad and when they get better.

    Nagios Core was originally designed to run under Linux,

    although it should wor under most other unices as well.

  • 8/10/2019 Nagios Module 1

    5/123

    www.gnugroup.org 5

    History of Naios

    History +)art

    )tt./00$$$naiosor0a,out0)istory

    http://www.nagios.org/about/historyhttp://www.nagios.org/about/history
  • 8/10/2019 Nagios Module 1

    6/123

    www.gnugroup.org 6

    System !e"uirements

    2)e only soft$are re"uirement for runnin Naios+ore is a mac)ine

    !unnin Linux 3or UNI4 %ariant5 Has net$or( access A + com.iler installed A $e, ser%er 3.referra,ly A.ac)e5

    d li,rary %ersion 167

  • 8/10/2019 Nagios Module 1

    7/123

    www.gnugroup.org 7

    #rere"uisites

    For Centos / Redhat distro A.ac)e #H# G++ com.iler GD de%elo.ment li,raries

    !!!!!!!!!!!!!!!!!!!Yum it !!!!!!!!!!!!!!!!!!!!! yum install )tt.d .). yum install cc li,c li,c-common yum install d d-de%el

  • 8/10/2019 Nagios Module 1

    8/123

    www.gnugroup.org 8

    Licensin

    Nagios Core is licensed under the ter!s of the

    GNU General Public License Version 2

    as published by the "ree #oftware "oundation.

  • 8/10/2019 Nagios Module 1

    9/123

    www.gnugroup.org 9

    Do$nloadin

    )tt./00$$$naiosor0do$nload

  • 8/10/2019 Nagios Module 1

    10/123

    www.gnugroup.org 10

    Advice for BeginnersAdvice for Beginners

    Relax - its going to take some time....Relax - its going to take some time....

    Use the quickstart instructionsUse the quickstart instructions

    Read the documentationRead the documentation

    Seek the help of othersSeek the help of others

  • 8/10/2019 Nagios Module 1

    11/123

    www.gnugroup.org 11

    'uic(start installation

    #rere"uisites

    Already Diccussed

    Also disa,le selinux

    8um u.date

    Already Diccussed

  • 8/10/2019 Nagios Module 1

    12/123

    www.gnugroup.org 12

    'uic(start installation

    User creation

    9 su : l

    9 0usr0s,in0useradd -m naios

    9 .ass$d naios

    Group Creation

    15 +reate a ne$ nagcmrou. for allo$in external commands to ,esu,mitted t)rou) t)e $e, interface

    ;5 Add ,ot) t)e naios user and t)e a.ac)e user to t)e rou.

    9 0usr0s,in0rou.add nacmd9 0usr0s,in0usermod -a -G nacmd naios

    9 0usr0s,in0usermod -a -G nacmd a.ac)e

  • 8/10/2019 Nagios Module 1

    13/123

    www.gnugroup.org 13

    'uic(start installation

    Do$nload Naios and t)e #luins)tt./00$$$naiosor0do$nload

    +reate a directory for storin t)e do$nloads

    9 m(dir

  • 8/10/2019 Nagios Module 1

    14/123

    www.gnugroup.org 14

    'uic(start installation

    Compile and Install NagiosExtract the Nagios source code tarball

    9 cd

  • 8/10/2019 Nagios Module 1

    15/123

    www.gnugroup.org 15

    'uic(start installation

    Compile and Install Nagios

    Run the Nagios conigure script" passing the name o the group #ou createdearlier li$e so%

    9 0confiure --&ith'command'group(nagcmd

    ) ma(e all

    Install binaries" init script" sample conig iles and set permissions on theexternal command director#

    9 ma(e install

    9 ma(e install-init9 ma(e install-confi

    9 ma(e install-commandmode

    Dont start Nagios yet- theres still more that needs to be done..

  • 8/10/2019 Nagios Module 1

    16/123

    www.gnugroup.org 16

    'uic(start installation

    Configure the We! Interface

    Install the Nagios &eb conig ile in the *pache cond director#

    9 ma(e install-$e,conf

    Create a nagiosadmin account or logging into the Nagios &eb interace

    Remem!er the passwor#ou assign to this account ' #ou+ll need it later

    htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

    Restart *pache to ma$e the ne& settings ta$e eect

    # service httpd restart

  • 8/10/2019 Nagios Module 1

    17/123

    www.gnugroup.org 17

    'uic(start installation

    Compile , Install the Nagios -lugins

    Extract the Nagios plugins source code tarball

    9 cd 11tar=

    9 cd naios-.luins-1>11

    Compile and install the plugins

    9 0confiure --$it)-naios-user?naios --$it)-naios-rou.?naios9 ma(e

    9 ma(e install

  • 8/10/2019 Nagios Module 1

    18/123

    www.gnugroup.org 18

    'uic(start installation

    .tart Nagios

    *dd Nagios to the list o s#stem serices and hae it automaticall# start &hen thes#stem boots

    9 c)(confi --add naios9 c)(confi naios on

    0eri# the sample Nagios coniguration iles

    9 0usr0local0naios0,in0naios -% 0usr0local0naios0etc0naioscf

    I there are no errors" start Nagios

    9 ser%ice naios start

    Add naios ser%ice torunle%els

    @erify confifile

  • 8/10/2019 Nagios Module 1

    19/123

    www.gnugroup.org 19

    'uic(start installation

    If you see me,

    I am configured

    And ready

  • 8/10/2019 Nagios Module 1

    20/123

    www.gnugroup.org 20

    Naios Arc)itecture*rchitecture

    Nagios is built on a serer / agents architecture

    Usually on a net$or( a Naios ser%er is runnin on a )ost

    and plugins are running on all the remote hosts t)at need to ,e monitored

    2)ese .luins send information to t)e ser%er $)ic) dis.lays t)em in a GUI

  • 8/10/2019 Nagios Module 1

    21/123

    www.gnugroup.org 21

    Naios Arc)itecture

  • 8/10/2019 Nagios Module 1

    22/123

    www.gnugroup.org 22

    #luins *hat *re -lugins1

    Naios .luins are stanalone e"tensionsto Naios +ore .ro%ide lo$-le%el intellience on )o$ to monitor an#thing and eer#thing $it)

    Naios +ore

    #luins operate as standalone applications ,ut are enerally designed to beexecuted b# Nagios Core

    #luinsprocess command-line arguments o a,out t)e ,usiness of .erformin as.ecific ty.e of c)ec(

    and then return the results to Nagios Core or urther processing

    #luins can eit)er ,e compiled binaries 3$ritten in + +BB etc5 or executablescripts 3s)ell #erl #H# etc5

    #luins act as an abstraction la#er,et$een t)e monitoring logic.resent in t)eNagios daemonand t)e actual ser%ices and )osts t)at are ,ein monitored

    2he upside o this t#pe o plugin architecture%

    2)at you can monitor ust a,out anyt)in you can t)in( of

    If you can automate t)e .rocess of c)ec(in somet)in you can monitor it $it)

    Naios

  • 8/10/2019 Nagios Module 1

    23/123

    www.gnugroup.org 23

    #luins

  • 8/10/2019 Nagios Module 1

    24/123

    www.gnugroup.org 24

    #luins3hat -lugins *re *ailable1

    2)ere are .luins currently a%aila,le to monitor many different (inds of de%ices andser%ices includin/

    H22# #O#7 IMA# C2# SSH DH+#

    +#U Load Dis( Usae Memory Usae +urrent Users

    Unix0Linux *indo$s and Net$are Ser%ers

    !outers and S$itc)es etc

    0c)ec()tt. :)el.

    4ical -lugins can be do&nloaded

    Nagios -lugins -ro5ect% http%//nagiosplugsourceorgenet/

    Nagios 6o&nloads -age% http%//&&&nagiosorg/do&nload/

    NagiosExchangeorg% http%//&&&nagiosexchangeorg/

  • 8/10/2019 Nagios Module 1

    25/123

    www.gnugroup.org 25

    !emote Monitorin Mec)anisms

    789 chec$:b#:ssh

    *dd Nagios to the list o s#stem serices and hae it automaticall# start &hen thes#stem boots

    Since you $ant to execute a command

    3a c)ec(-commandF or a naios .luin to et t)e state of some .rocess on t)e remote)osts5

    2)e o,%ious solution is to run it t)rou) a remote s)ell on t)e taret system -

    ss) user)ost FcommandF

    e

    ss) ilnode7ls -l 0,in

    Naios )as a c)ec(,yss) command t)at $or(s in a similar manner

    2)is re"uires t)e taret to )a%e an ssh#server running

    you need to set u. naios account on t)e remote )ost and arrane for non-interacti%eaut)entication 3e (ey-,ased aut)entication or ,y referin to username and .ass$ordsin a confiuration file5

    *ill execute ls -l 0,in+ommand on remote system

    mailto:ilg@node03mailto:ilg@node03
  • 8/10/2019 Nagios Module 1

    26/123

    www.gnugroup.org 26

    !emote Monitorin Mec)anisms

    Desin O%er%ie$

  • 8/10/2019 Nagios Module 1

    27/123

    www.gnugroup.org 27

    !emote Monitorin Mec)anisms

    7;9 nrpe

    NR-E stands or Nagios Remote $rocess %"ecution%

    2)e N!#E addon is desined to allo$ you to execute Naios .luins on remoteLinux/Unix machines

    2)e main reason for doin t)is is to allo$ Naios to monitor local resources 3li(e +#U

    load memory usae etc5 on remote mac)inesSince t)ese .u,lic resources are not usually ex.osed to external mac)ines an aentli(e N!#E must ,e installed on t)e remote Linux0Unix mac)ines

    2)is is a !emote Aent arc)itecture /

    An nrpeaent on t)e taret executes t)e re"uested c)ec(-commands and re.orts

    ,ac( t)e results /Nagios 7< nagios host nrpe9 < nrpe on remote host < command

  • 8/10/2019 Nagios Module 1

    28/123

    www.gnugroup.org 28

    !emote Monitorin Mec)anisms

    Desin O%er%ie$

  • 8/10/2019 Nagios Module 1

    29/123

    www.gnugroup.org 29

    !emote Monitorin Mec)anisms

    7=9 chec$:nt

    !emote Aent mec)anism s.ecifically for *indo$s systems +once.tually similar toc)ec(,yss) and c)ec(nr.e

    Monitorin .ri%ate ser%ices or attri,utes of a *indo$s mac)ine re"uires t)at you installan aent on it

    2)is aent acts as a .roxy ,et$een t)e Naios .luin t)at does t)e monitorin and t)e

    actual ser%ice or attri,ute of t)e *indo$s mac)ine

    *it)out installin an aent on t)e *indo$s ,ox Naios $ould ,e una,le to monitor.ri%ate ser%ices or attri,utes of t)e *indo$s ,ox

    *e $ill ,e installin t)e NS+lientBB addon on t)e *indo$s mac)ine and usin t)ec)ec(nt .luin to communicate $it) t)e NS+lientBB addon

    Note/ 2)e c)ec(nt .luin s)ould already ,e installed on t)e Naios ser%er

  • 8/10/2019 Nagios Module 1

    30/123

    www.gnugroup.org 30

    !emote Monitorin Mec)anisms

    Desin O%er%ie$

  • 8/10/2019 Nagios Module 1

    31/123

    www.gnugroup.org 31

    !emote Monitorin Mec)anisms

    7>9 N.C*

    N.C* is Nagios .erice Chec$ *cceptor

    ItFs an additional daemon on your Naios )ost

    Acce.ts and .rocesses c)ec( results su,mitted ,y ot)er Naios )osts or any ot)er.roram t)at manaes to deli%er an NS+A messae t)at says somet)in useful a,out

    Ser%ice

    #rocess

    Soft$are or

    Hard$are state on a 3remote5 )ost

    As suc) NS+A is instrumental in remote and distri,uted monitorin

  • 8/10/2019 Nagios Module 1

    32/123

    www.gnugroup.org 32

    !emote Monitorin Mec)anisms

    Desin O%er%ie$

  • 8/10/2019 Nagios Module 1

    33/123

    Monitorin *indo$s Mac)ines4erie&

    Collo$in t)ree ste.s $ill )a..en on a %ery )i) le%el $)en Naios3installed on t)e naios-ser%er5 monitors a ser%ice 3for e dis( s.aceusae5 on t)e remote *indo$s )ost

    Naios $ill execute chec$:nt command on nagios'sererandre"uest it to monitor dis$ usage on remote &indo&s host

    2)e chec$:nt on the nagios'serer &ill contact the N.Client??ser%ice on remote $indo$s )ost and re"uest it to execute t)[email protected]*CE on the remote host

    2)e results of t)e [email protected]*CE command$ill ,e returned ,ac(,y NS+lientBB daemon to t)e c)ec(nt on naios-ser%er

  • 8/10/2019 Nagios Module 1

    34/123

    Monitorin *indo$s Mac)ines

    Follo&ing lo& summariAes the aboe explanation%

    Nagios .erer 7chec$:nt9 J:K !emote )ost 3NS+lientBB5 J:[email protected]*CE

    Nagios .erer 7chec$:nt9 J: !emote )ost 3NS+lientBB5 J: [email protected]*CE

    7returns dis$ space usage9

  • 8/10/2019 Nagios Module 1

    35/123

    Monitorin *indo$s Mac)ines

    II >steps to setup nagios on remote &indo&s host

    1 Install NS+lientBB on t)e remote $indo$s ser%er

    6o&nload N.C- B=8 7N.Client??'3in=;'B=8msi9 from NS+lientBB #roectNS+lientBB is an open source &indo&s sericet)at allo$s perormance metricsto ,eat)ered ,y Naios for $indo$s ser%ices

    Go t)rou) t)e follo$in fi%e NS+lientBB installation ste.s to et t)e installationcom.leted

    315 NS+lientBB *elcome Screen

    3;5 License Areement Screen

    375 Select Installation o.tion and location Use t)e default o.tion and clic( next

    3>5 !eady to Install Screen +lic( on Install to et it started

    35 Installation com.leted Screen

  • 8/10/2019 Nagios Module 1

    36/123

    Monitorin *indo$s Mac)ines

  • 8/10/2019 Nagios Module 1

    37/123

    Monitorin *indo$s Mac)ines

    7 odi# the N.Cini

    315 Modify NS+ini and uncomment dll/ Edit t)e +/#roram CilesNS+lientBBNS+inifile and uncomment eer#thing under PmodulesQ except RemoteConigurationdlland +)ec(*MIdll1

    PmodulesQ

    R9 NS+LIEN2BB MODULES

    R9 A list $it) DLLs to load at startu.

    R 8ou $ill need to ena,le some of t)ese for NS+lientBB to $or(

    R

    R

    R N O 2 I + E - 8 O U H A @ E 2 O E D I 2 2 H I S

    R

    i i i d )i

  • 8/10/2019 Nagios Module 1

    38/123

    Monitorin *indo$s Mac)ines

    R

    CileLoerdll

    +)ec(Systemdll

    +)ec(Dis(dll

    NS+lientListenerdllN!#EListenerdll

    Sys2raydll

    +)ec(E%entLodll

    +)ec(Hel.ersdllR+)ec(*MIdll

    i i i d )i

  • 8/10/2019 Nagios Module 1

    39/123

    Monitorin *indo$s Mac)inesR

    R !emote+onfiuration IS AN E42!EM EA!L8 IDEA SO DON2 USE CO!#!ODU+2ION EN@I!OMNEM2S

    R!emote+onfiurationdll

    R NS+A Aent is a ne$ ,eta module use $it) care

    NS+AAentdll

    R LUA scri.t module used to $rite your o$n c)ec( deamon 3sort of5 early ,eta

    LUAScri.tdll

    R Scri.t to c)ec( external scri.ts and0or internal aliases early ,eta

    +)ec(ExternalScri.tsdll

    R +)ec( ot)er )osts t)rou) N!#E extreme ,eta and .ro,a,ly a ,it danerous /5

    N!#E+lientdll

  • 8/10/2019 Nagios Module 1

    40/123

    Monitorin *indo$s Mac)ines

    375 odi# N.Cini and uncomment port Edit t)e +/#roramCilesNS+lientBBNS+ini file and uncomment t)e .ort9 underPNS+lientQ section

    R9 NS+LIEN2 #O!2 NUM&E!

    R 2)is is t)e .ort t)e NS+lientListenerdll $ill listen to

    port(8;>D

  • 8/10/2019 Nagios Module 1

    41/123

    Monitorin *indo$s Mac)ines

    >9 odi# N.Cini and speci# pass&ord 8ou can also s.ecify a.ass$ord t)e naios ser%er needs to use to remotely access t)eNS+lientBB aent

    PSettinsQ

    R9 O&CUS+A2ED #ASS*O!D

    R 2)is is t)e same as t)e .ass$ord o.tion ,ut )ere you can store t)e.ass$ord in an o,fuscated manner

    R NO2I+E o,fuscation is NO2 t)e same as encry.tion someone$it) access to t)is file can still fiure out t)e

    R .ass$ord Its ust a ,it )arder to do it at first lance

    Ro,fuscated.ass$ord?T$AUUd4lAAU$ASDAA&

    R

    R9 #ASS*O!D

    Monitorin *indo$s Mac)ines

  • 8/10/2019 Nagios Module 1

    42/123

    Monitorin *indo$s Mac)ines

    R 2)is is t)e .ass$ord 3-s5 t)at is re"uired to access NS+lient remotelyIf you lea%e t)is ,lan( e%eryone $ill ,e a,le to access t)e daemonremotly

    pass&ord(#;.ecure-ass&ord

    > Start t)e NS+lientBB Ser%ice

    Start t)e NS+lientBB ser%ice

    eit)er from t)e +ontrol #anel -K Administrati%e tools -K Ser%ices -KSelect VNS+lient.. 3Naios5 711> ;W-7-1; $7;X and clic( onstart 3or5 +lic( on VStart -K All #rorams -K NS+lientBB -K Start

    NS+lientBB 3*in7;5 -lease note that this &ill start the N.Client??as a &indo&s serice

    Later if you modify anyt)in in t)e NS+ini file you s)ould restart t)eVNS+lient.. 3Naios5 711> ;W-7-1; $7;X from t)e $indo$sser%ice

    M i i *i d M )i

  • 8/10/2019 Nagios Module 1

    43/123

    Monitorin *indo$s Mac)ines

    @erify t)at t)e $indo$s-ser%er tem.late is ena,led under/usr/local/nagios/etc/ob5ects/templatescg

    9 *indo$s )ost definition tem.late - 2)is is NO2 a real )ost ust a tem.late

    define )ostY

    name $indo$s-ser%erR 2)e name of t)is )ost tem.late

    use eneric-)ost R In)erit default %alues from t)e eneric- )ost tem.late

    c)ec(.eriod ;>xZ R &y default *indo$s ser%ers are monitored round t)e cloc(

    c)ec(inter%al R Acti%ely c)ec( t)e ser%er e%ery minutes

    Monitorin *indo$s Mac)ines

  • 8/10/2019 Nagios Module 1

    44/123

    Monitorin *indo$s Mac)ines

    retry$interval % & #chedule host chec retries at %!inute intervals

    !a'$chec$atte!pts %( & Chec each server %( ti!es)!a'*

    chec$co!!and chec+host+alive & efault co!!and to chec ifservers are -alive-

    notification$period /'0 & #end notification out at any ti!e+ day or night

    notification$interval 1( & 2esend notifications every 1(!inutes

    notification$options d,r & 3nly send notifications forspecific host statescontact$groups ad!ins & Notifications get sent to the

    ad!ins by default

    i i i d )i

  • 8/10/2019 Nagios Module 1

    45/123

    Monitorin *indo$s Mac)ines

    )ostrou.s $indo$s-ser%ers R Host rou.s t)at *indo$sser%ers s)ould ,e a mem,er of

    reister R DON2 !EGIS2E! 2HIS : I2STUS2 A 2EM#LA2E

    [

    ; Uncomment &indo&scg in /usr/local/nagios/etc/nagioscg

    9 Definitions for monitorin a *indo$s mac)ine

    cffile?0usr0local0naios0etc0o,ects0$indo$scf

    M i i *i d M )i

  • 8/10/2019 Nagios Module 1

    46/123

    Monitorin *indo$s Mac)ines

    address 1\;16W1> R I# address of t)e remote $indo$s)ost

    [

    > 6eine &indo&s serices that should be monitored

    Collo$in are t)e default $indo$s ser%ices t)at are already ena,led int)e sam.le $indo$scf Ma(e sure to u.date t)e )ostname on t)eseser%ices to reflect t)e )ostname defined in t)e a,o%e ste.

    define ser%iceY

    use eneric-ser%ice

    )ostname remote-$indo$s-)ost

    ser%icedescri.tion NS+lientBB @ersion

    c)ec(command c)ec(nt+LIEN2@E!SION

    [

    Monitorin *indo$s Mac)ines

  • 8/10/2019 Nagios Module 1

    47/123

    Monitorin *indo$s Mac)ines

    define ser%iceYuse eneric-ser%ice

    )ostname remote-$indo$s-)ost

    ser%icedescri.tion U.time

    c)ec(command c)ec(ntU#2IME

    [

    define ser%iceY

    use eneric-ser%ice)ostname remote-$indo$s-)ost

    ser%icedescri.tion +#U Load

    c)ec(command c)ec(nt+#ULOAD-l W\

    [

    Monitorin *indo$s Mac)ines

  • 8/10/2019 Nagios Module 1

    48/123

    Monitorin *indo$s Mac)ines

    define ser%iceYuse eneric-ser%ice

    )ostname remote-$indo$s-)ost

    ser%icedescri.tion U.time

    c)ec(command c)ec(ntU#2IME

    [

    define ser%iceY

    use eneric-ser%ice)ostname remote-$indo$s-)ost

    ser%icedescri.tion +#U Load

    c)ec(command c)ec(nt+#ULOAD-l W\

    [

    Monitorin *indo$s Mac)ines

  • 8/10/2019 Nagios Module 1

    49/123

    Monitorin *indo$s Mac)ines

    Enable -ass&ord -rotection

    If you s.ecified a .ass$ord in t)e NS+ini file of t)e NS+lientBBconfiuration file on t)e *indo$s mac)ine

    you]ll need to modi# the chec$:nt commanddefinition to include t)e.ass$ord

    Modify t)e /usr/local/nagios/etc/commandscg file and addpass&ordas s)o$n ,elo$

    define commandY

    commandname c)ec(nt

    commandline ^USE!1^0c)ec(nt -H ^HOS2ADD!ESS^ -. 1;>W\-s My;Secure^#ass$ord -% ^A!G1^ ^A!G;^

    [

    Monitorin *indo$s Mac)ines

  • 8/10/2019 Nagios Module 1

    50/123

    Monitorin *indo$s Mac)ines

    H 0eri# Coniguration and Restart Nagios@erify t)e naios confiuration files as s)o$n ,elo$

    Pnaios-ser%erQ90usr/local/nagios/bin/nagios '

    /usr/local/nagios/etc/nagioscg

    2otal *arnins/

    2otal Errors/

    2)ins loo( o(ay - No serious .ro,lems $ere detected durin t)e .re-fli)t c)ec(

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    51/123

    Monitor !emote Linux Host

    I 4erie&%

    Collo$in t)ree ste.s $ill )a..en on a %ery )i) le%el $)en Naios 3installed on t)enaios-ser%ers5 monitors a ser%ice 3for e dis( s.ace usae5 on t)e remote Linux )ost

    Nagios &ill execute chec$:nrpe command on naios-ser%er and re"uest it to monitordis( usae on remote )ost usin c)ec(dis( command

    2)e chec$:nrpe on the nagios'serer &ill contact the NR-E daemon on remote

    )ost and re"uest it to execute t)e c)ec(dis( on remote )ost

    2)e results of t)e chec$:dis$ command $ill ,e returned ,ac( ,y NR-E daemon tot)e chec$:nrpeon naios-ser%er

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    52/123

    Monitor !emote Linux Host

    II steps to install Nagios -lugins and NR-E on the remote host8 6o&nload Nagios -lugins and NR-E *dd'on

    Do$nload follo$in files from Naiosor and mo%e to0)ome0do$nloads/

    nagios'plugins'8>88targA nrpe';8;targA

  • 8/10/2019 Nagios Module 1

    53/123

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    54/123

    Monitor !emote Linux Host

    Premote)ostQ9 /conigure ''&ith'nagios'user(nagios ''&ith'nagios'group(nagios ''enable'redhat'pthread'&or$around

    Premote)ostQ9 ma(e

    Premote)ostQ9 ma(e install

    Premote)ostQ9 c)o$n naiosnaios 0usr0local0naios Premote)ostQ9 c)o$n -! naiosnaios 0usr0local0naios0li,exec0

    Note/ 4n Red Jat" For me the /conigure command &as hanging

    &ith the the message% Kchec$ing or redhat spopen problemM*dd ''enable'redhat'pthread'&or$around to the /conigurecommand as a &or$'around or the aboe problem

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    55/123

    Monitor !emote Linux Host

    .etup NR-E to run as daemon 7ie as part o xinetd9% Modify t)e 0etc0xinetdd0nr.e to add t)e i.-address of t)e Naios

    monitorin ser%er to t)e onlyfrom directi%e

    Note t)at t)ere is a s.ace after t)e 1;Z1 and t)e naiosmonitorin ser%er i.-address 3in t)is exam.le naios monitorin ser%eri.-address is/ 1\;16W1;5

    onlyfrom ? 1;Z18;8HD8;

    Modify t)e /etc/sericesand add t)e follo$in at t)e end of t)e file

    nrpe HHH/tcp ) NR-E

    Start t)e ser%ice

    Premote)ostQ9serice xinetd restart

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    56/123

    Monitor !emote Linux Host 0eri# &hether NR-E is listening

    Premote)ostQ9 netstat -at _ re. nr.e

    tc. /nr.e / LIS2EN

    0eri# to ma$e sure the NR-E is unctioning properl#

    Premote)ostQ9 0usr0local0naios0li,exec0c)ec(nr.e -H local)ost

    N!#E %;1;

    H odi# the /usr/local/nagios/etc/nrpecg

    2)e nr.ecf file located on t)e remote )ost contains t)e commandst)at are needed to c)ec( t)e ser%ices on t)e remote )ost

    &y default t)e nr.ecf comes $it) fe$ standard c)ec( commands assam.les

    c)ec(users and c)ec(load are s)o$n ,elo$ as an exam.le

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    57/123

    Monitor !emote Linux Host

    commandPc)ec(usersQ?0usr0local0naios0li,exec0c)ec(users -$ -c 1commandPc)ec(loadQ?0usr0local0naios0li,exec0c)ec(load -$ 11 -c7;;

    In all t)e c)ec( commands t)e V'&M stands or K3arningM and V'cMstands or KCriticalM

    for e in t)e c)ec(dis( command ,elo$ if t)e a%aila,le dis( s.ace etsto ;` of less naios $ill send $arnin messae

    If it ets to 1` or less naios $ill send critical messae +)ane t)e%alue of V-c and V-$ .arameter ,elo$ de.endin on your en%ironment

    commandchec$:dis$O(/usr/local/nagios/libexec/chec$:dis$ '& ;BP 'c8BP 'p /de/hda8

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    58/123

    III >Coniguration steps on the Nagios monitoring serer to monitor remote host%

    8 6o&nload NR-E *dd'on

    Do$nload nr.e-;1;tar= from Naiosor and mo%e to 0)ome0do$nloads/te/

    ; Install chec$:nrpe on the nagios monitoring serer

    Pnaios-ser%erQ9 tar x%f= nr.e-;1;tar=

    Pnaios-ser%erQ9 cd nr.e-;1;

    Pnaios-ser%erQ9 0confiure

    Pnaios-ser%erQ9 ma(e all

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    59/123

    Pnaios-ser%erQ9 ma(e install-.luin 0confiure $ill i%e a confiuration summary as s)o$n ,elo$/

    +onfiuration summary for nr.e ;1; -71-;W /

    General O.tions/

    JJJJJJJJ-

    N!#E .ort/ 666

    N!#E user/ naios

    N!#E rou./ naios

    Naios user/ naios

    Naios rou./ naios

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    60/123

    Note/ I got the Kchec$ing or ..L headers conigure% error%Cannot ind ssl headersMerror messae $)ile .erformin 0confiure Install o.enssl-de%el as s)o$n ,elo$ and runt)e 0confiure aain to fix t)e .ro,lem

    Pnaios-ser%erQ9 r.m -i%) o.enssl-de%el-\Za->716i7W6r.m (r,-de%el-17>->Zi7W6r.m=li,-de%el-1;1;-1;i7W6r.m e;fs.ros-de%el-17-1;

    el>i7W6r.m

    $arnin/ o.enssl-de%el-\Za->716i7W6r.m/ @7 DSA sinature/ NOE8 (ey ID d,>;a6e

    #re.arin 9999999999999999999999999999999999999999999 P1`Q

    1/e;fs.ros-de%el 9999999999999999999999999999999999999999999 P ;`Q

    ;/(r,-de%el 9999999999999999999999999999999999999999999 P `Q

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    61/123

    host deinition sample% define )ostY

    use linux-ser%er

    )ostname remote)ost

    alias !emote Host

    address 1\;16W17

    contactrou.s admins

    [

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    62/123

    Ser%ice definition sam.le/

    define ser%iceY

    use eneric-ser%ice

    ser%icedescri.tion !oot #artition

    contactrou.s admins

    c)ec(command c)ec(nr.ec)ec(dis(

    [

    Note/ In all t)e a,o%e exam.les re.lace remote)ost $it) t)e corres.ondin)ostname of your remote)ost

    Monitor !emote Linux Host

  • 8/10/2019 Nagios Module 1

    63/123

    > Restart the nagios serice!estart t)e naios as s)o$n ,elo$ and loin to t)e naios $e,3)tt./00naios-ser%er0naios05 to %erify t)e status of t)e remote)ost linuxse%er t)at $as added to naios for monitorin

    Pnaios-ser%erQ9 serice nagios reload

    Monitor Net$or( S$itc) and #orts

  • 8/10/2019 Nagios Module 1

    64/123

    = *dd a ne& host or the s&itch to be moniteredIn t)is exam.le I]%e defined a )ost to monitor t)e core s&itch in t)e/usr/local/nagios/etc/ob5ects/s&itchcgfile

    +)ane t)e address directi%e to your s$itc) i.-address accordinly

    define )ostY use eneric-s$itc)

    )ostname core's&itch

    alias +isco +ore S$itc)

    address 8;8HD8B

    )ostrou.s s$itc)es

    [

    Monitor Net$or( S$itc) and #orts

  • 8/10/2019 Nagios Module 1

    65/123

    > *dd common serices or all s&itches

    Dis.layin t)e uptime o the s&itchand

    %erifyin $)et)er s&itch is alieare common ser%ices for all s$itc)es

    So define t)ese ser%ices under t)e s$itc)es )ostrou.name as s)o$n ,elo$

    9 Ser%ice deinition to ping the s&itch using chec$:ping

    define ser%iceY

    use eneric-ser%ice

    )ostrou.name s$itc)es

    ser%icedescri.tion #ING

    c)ec(command c)ec(.in;;`66`

    normalc)ec(inter%al

    retryc)ec(inter%al 1

    [

    Monitor Net$or( S$itc) and #orts

  • 8/10/2019 Nagios Module 1

    66/123

    9 Ser%ice definition to monitor s$itc) u.time usin c)ec(snm.

    define ser%iceY

    use eneric-ser%ice

    )ostrou.name s$itc)es

    ser%icedescri.tion U.time

    c)ec(command c)ec(snm.-+ .u,lic -o sysU.2ime

    [

    Monitor Net$or( S$itc) and #orts

  • 8/10/2019 Nagios Module 1

    67/123

    H *dd serice to monitor an actie s&itch portUse chec$:snmp to monitor the speciic portas s)o$n ,elo$

    2)e follo$in t$o ser%ices monitors .ort91 and .ort9 2o add additional.orts c)ane t)e %alue ifO.erStatusn accordinly ie n defines t)e .ort9

    9 Monitor status of .ort num,er 1 on t)e +isco core s$itc) define ser%iceY

    use eneric-ser%ice

    )ostname core-s$itc)

    ser%icedescri.tion #ort 1 Lin( Status

    c)ec(command c)ec(snm.-+ .u,lic -o ifO.erStatus1 -r 1 -m!C+1;17-MI&

    [

    Monitor Net$or( S$itc) and #orts

  • 8/10/2019 Nagios Module 1

    68/123

    9 Monitor status of .ort num,er on t)e +isco core s$itc) define ser%iceY

    use eneric-ser%ice

    )ostname core-s$itc)

    ser%icedescri.tion #ort Lin( Status c)ec(command c)ec(snm.-+ .u,lic -o ifO.erStatus -r 1 -m !C+1;17-MI&

    [

    Monitor Net$or( S$itc) and #orts

  • 8/10/2019 Nagios Module 1

    69/123

    *dd serices to monitor multiple s&itch ports togetherSometimes you may need to monitor the status o multiple portscom,ined toet)er

    ie Naios s)ould send an alert" een i one o the port is do&n

    In t)is case define t)e follo$in ser%ice to monitor multi.le .orts

    9 Monitor .orts 1 - 6 on t)e +isco core s$itc) define ser%iceY

    use eneric-ser%ice

    )ostname core-s$itc)

    ser%icedescri.tion #orts 1-6 Lin( Status

    c)ec(command c)ec(snm.-+ .u,lic -o ifO.erStatus1 -r 1 -m !C+1;17-MI& -oifO.erStatus; -r 1 -m !C+1;17-MI& -o ifO.erStatus7 -r 1 -m !C+1;17-MI& -oifO.erStatus> -r 1 -m !C+1;17-MI& -o ifO.erStatus -r 1 -m !C+1;17-MI& -oifO.erStatus6 -r 1 -m !C+1;17-MI&

    Monitor Net$or( S$itc) and #orts

  • 8/10/2019 Nagios Module 1

    70/123

    9 0etc0rcd0initd0naios sto. Sto..in naios/ done

    9 0etc0rcd0initd0naios start

    Startin naios/ done

    @erify t)e status of t)e s$itc) from t)e Naios $e, UI/ )tt./00Ynaios-ser%er[0naios as s)o$n ,elo$/

    +onfiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    71/123

    www.gnugroup.org 71

    +onfiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    72/123

    www.gnugroup.org 72

    Resource File7s9

    !esource files can ,e used to store user'deined macros

    2)e main .oint of )a%in resource files is to use them to store sensitieconiguration inormation 7li$e pass&ords9"$it)out ma(in t)em a%aila,le tot)e +GIs

    Cormat/ resource:ile(Qile:name

    Example%

    resource:ile(/usr/local/nagios/etc/resourcecg

    +onfiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    73/123

    www.gnugroup.org 73

    &ain Configuration 'ile

    2)e main confiuration file contains a num,er of directi%es t)at affect )o$t)e Naios daemon o.erates

    2)is conig ile is read b# both the Nagios daemonand t)e +GIs

    2his is &here #ouSre going to &ant to get started in #our conigurationadentures

    Conig File Location

    2)e main confiuration file is usually named nagioscg and located int)e /usr/local/nagios/etc/ director#

    +onfiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    74/123

    www.gnugroup.org 74

    CGI Coniguration File

    2)e +GI confiuration file contains a number o directies that aect theoperation o the CGIs

    It also contains a reference t)e main confiuration file

    so t)e +GIs (no$ )o$ you]%e confiured Naios and

    $)ere your o,ect defintions are stored

    * sample CGI coniguration ile 7/usr/local/nagios/etc/cgicg9 is installed or

    #ou &hen #ou follo$ t)e "uic(start installation uide

    +onfiuration o%er%ie$

    Main confiuration file o.tions

  • 8/10/2019 Nagios Module 1

    75/123

    www.gnugroup.org 75

    Main confiuration file o.tions

    Lo Cile

    Cormat/ log:ile(Qile:name

    Exam.le/

    log:ile(/usr/local/nagios/ar/nagioslog

    2)is %aria,le s.ecifies $)ere Naios s)ould create its main lo file

    2)is s)ould ,e t)e first %aria,le t)at you define in your confiuration file as Naios$ill try to $rite errors t)at it finds in t)e rest of your confiuration data to t)is file

    If you )a%e lo rotation ena,led t)is file $ill automatically ,e rotated e%ery )ourday $ee( or mont)

    +onfiuration o%er%ie$

    Main confiuration file o.tions

  • 8/10/2019 Nagios Module 1

    76/123

    www.gnugroup.org 76

    Main confiuration file o.tions

    2emp File

    Cormat/ tem.file?filenameK

    Exam.le/

    temp:ile(/usr/local/nagios/ar/nagiostmp

    2)is is a tem.orary file t)at Naios .eriodically creates to use $)en u.datin commentdata status data etc

    +onfiuration o%er%ie$Main confiuration file o.tions

  • 8/10/2019 Nagios Module 1

    77/123

    www.gnugroup.org 77

    Main confiuration file o.tions

    .tatus File

    Cormat/ status:ile(Qile:name

    Exam.le/

    status:ile(/usr/local/nagios/ar/statusdat

    2)is is t)e file t)at Naios uses to store t)e current status comment and do$ntime information

    2)is file is used ,y t)e +GIs so t)at current monitorin status can ,e re.orted %ia a $e, interface

    2)e +GIs must )a%e read access to t)is file in order to function .ro.erly

    Note/ 2)is file is deleted e%ery time Naios sto.s and recreated $)en it starts

    O,ect confiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    78/123

    www.gnugroup.org 78

    3hat *re 4b5ects1

    O,ects are all t)e elements t)at are in%ol%ed in t)e monitorin and notificationloic 2y.es of o,ects include/

    .erices .erice Groups Josts Jost Groups Contacts Contact Groups Commands 2ime -eriods Notiication Escalations Notiication and Execution 6ependencies

    O,ect confiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    79/123

    www.gnugroup.org 79

    3here *re 4b5ects 6eined1

    O,ects can ,e defined in one or more confiuration files and0or directories t)at yous.ecify usin t)ecg:ileand0orcg:dirdirecti%es in t)e main confiuration file

    Ho$ Are O,ects Definedb

    O,ects are defined in a flexi,le tem.late format $)ic) can ma(e it muc) easier tomanae your Naios confiuration in t)e lon term

    O,ect confiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    80/123

    www.gnugroup.org 80

    Host Grou.s are rou.s of one or more )osts

    Host rou.s can ma(e it easier to

    315 %ie$ t)e status of related )osts in t)e Naios $e, interface and

    3;5 sim.lify your confiuration t)rou) t)e use of o,ect tric(s

    O,ect confiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    81/123

    www.gnugroup.org 81

    .ericesare one of t)e central o,ects in t)e monitorin loic

    Ser%ices are associated $it) )osts and can ,e/

    *ttributes o a host 7C-U load" dis$ usage" uptime" etc9

    .erices proided b# the host 7J22-" -4-=" F2-" ..J" etc9

    4ther things associated &ith the host 76N. records" etc9

    O,ect confiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    82/123

    www.gnugroup.org 82

    Ser%ice Grou.s are rou.s of one or more ser%ices

    Ser%ice rou.s can ma(e it easier to

    315 %ie$ t)e status of related ser%ices in t)e Naios $e, interface and

    3;5 sim.lify your confiuration t)rou) t)e use of o,ect tric(s

    O,ect confiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    83/123

    www.gnugroup.org 83

    2imeperiodsare are used to control/

    *)en )osts and ser%ices can ,e monitored

    *)en contacts can recei%e notifications

    O,ect confiuration o%er%ie$

  • 8/10/2019 Nagios Module 1

    84/123

    www.gnugroup.org 84

    Commandsare used to tell Naios $)at .rorams scri.ts etc it s)ould

    execute to .erform/

    Host and ser%ice c)ec(s

    Notifications

    E%ent )andlers

    and more

    O,ect Definitions

    Introduction

  • 8/10/2019 Nagios Module 1

    85/123

    www.gnugroup.org 85

    *it) Naios youFre oin to monitor )osts and ser%ices

    &ein a flexi,le frame$or( Naios lets you define t)ose yourself as o,ectdefinitions in confiuration files

    *)en creatin and0or editin confiuration files (ee. t)e follo$in in mind/

    Lines t)at start $it) a F9F c)aracter are ta(en to ,e comments and are not.rocessed

    Directi%e names are case-sensiti%e

    +)aracters t)at a..ear after a semicolon 3R5 in confiuration lines are treatedas comments and are not .rocessed

    #at) 0usr0local0naios0etc0o,ect0

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    86/123

    www.gnugroup.org 86

    Jost 6einition

    Host monitorin only tells you if a )ost is u. ieres.ondin to a .in from t)e Naios ser%er

    A sam.le definition of a )ost is as follo$s/

    define )ost Y )ostname

    linux,ox1 )ostrou.s

    linuxser%ers alias Linux

    Ser%er 1 address 1;1 c)ec(command c)ec(-)ost-ali%e c)ec(inter%al retryinter%al 1 maxc)ec(attem.ts c)ec(.eriod ;>xZ contactrou.s l inux-admins notificationinter%al 7 notification.eriod ;>xZ notificationo.tions dur

    [

    2)e slide defines a Linux ,ox t)at $ill uset)e chec$'host'alie command to ma(esure t)e ,ox is u. and runnin

    2)e test $ill ,e .erformed e%ery fi%eminutes

    and after fi%e failed tests

    it $ill assume t)e )ost is do$n

    If it is do$n a notification $ill ,e sent oute%ery 7 minutes

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    87/123

    www.gnugroup.org 87

    6etermining .tatus and Reachabilit# o Net&or$ Josts

    Naios is a,le to determine $)et)er t)e )osts youFre monitorin are in a 643N orUNRE*CJ*TLE state

    2)ese are %ery different 3alt)ou) related5 states and can )el. you "uic(ly

    determine t)e root cause of net$or( .ro,lems

    HereFs )o$ t)e reac)a,ility loic $or(s to distinuis) ,et$een t)ese t$o states

    O,ect Definitions

    i i d

  • 8/10/2019 Nagios Module 1

    88/123

    www.gnugroup.org 88

    6etermining .tatus andReachabilit# o Net&or$ Josts

    2a(e a loo( at t)e sim.le net$or(diaram Cor t)is exam.le letsassume youFre monitorin all t)e )osts3ser%er routers s$itc)es etc5 t)at are.ictured Naios is installed andrunnin on t)e Naios )ost

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    89/123

    www.gnugroup.org 89

    6eining -arent/Child Relationships

    No$ t)at you (no$ $)at t)e .arent0c)ild

    relations)i.s loo( li(e for )osts t)at are

    ,ein monitored )o$ do you confiure Naios to reflect

    t)emb

    2he parents directie in #our hostdeinitions

    allo&s #ou to do this

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    90/123

    www.gnugroup.org 90

    6eining -arent/Child Relationships

    define )ostY

    )ostname Nagios R -- 2)e local )ost )as no .arent - it is t)eto.most )ost

    [

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    91/123

    www.gnugroup.org 91

    define )ost

    Y

    )ostname 3eb

    .arents .&itch8

    [

    define )ost

    Y

    )ostname tp

    .arents .&itch8

    [

    define )ost

    Y

    )ostname tp

    .arents .&itch8

    [

    define )ost

    Y

    )ostname .&itch;

    .arents Router8

    [

    define )ost

    Y

    )ostname Router8

    .arents .&itch8

    [

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    92/123

    www.gnugroup.org 92

    Reachabilit# Logic in *ction

    No$ t)at youFre confiured Naios$it) t)e .ro.er .arent0c)ildrelations)i.s for your )osts

    letFs see $)at )a..en $)en .ro,lems

    arise

    Assume t)at t$o )osts - 3eb andRouter8 ' go oline

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    93/123

    www.gnugroup.org 93

    Reachabilit# Logic in *ction

    *)en )osts c)ane state 3ie fromU# to DO*N5

    t)e )ost reac)a,ility loic in Naios(ic(s in

    2)e reac)a,ility loic $ill initiate.arallel c)ec(s of t)e .arents andc)ildren of $)ate%er )osts c)anestate

    2)is allo$s Naios to "uic(lydetermine t)e current status of yournet$or( infrastructure $)en c)anesoccur

    O,ect Definitions

    Reachabilit# Logic in *ction

  • 8/10/2019 Nagios Module 1

    94/123

    www.gnugroup.org 94

    Reachabilit# Logic in *ction

    Final conclusion Naios $ill determine t)at *e, and !outer1

    are ,ot) in DO*N states ,ecause t)e .at)to t)ose )osts is not ,ein ,loc(ed

    Naios $ill determine t)at all t)e )osts,eneat) !outer1 are all in anUN!EA+HA&LE state ,ecause Naios canFtreac) t)em

    !outer1 is DO*N and is ,loc(in t)e .at) tot)ose ot)er )osts

    2)ose )osts mi)t ,e runnin fine or t)eymi)t ,e offline -

    Naios doesnFt (no$ ,ecause it canFt reac)t)emJence Nagios considers them to beUNRE*CJ*TLE instead o 643N

    O,ect Definitions

    define )ostrou. define )ostrou.

  • 8/10/2019 Nagios Module 1

    95/123

    www.gnugroup.org 95

    Y

    )ostrou.name linux-ser%ers

    Alias Linux ser%ers

    Mem,ers linux,ox1linux,ox;

    [

    Y

    )ostrou.name aix-ser%ers

    Alias AI4 ser%ers

    Mem,ers aix,ox1aix,ox;

    [

    define )ostrou.

    Y

    )ostrou.name unix-ser%ers

    Alias UNI4 ser%ers

    Mem,ers llinux-ser%ersaix-ser%ers

    [

    hostgroup:nameS)ort uni"ue name of t)e)ost rou.

    alias Descri.ti%e name of t)e )ost rou.

    members List of all )osts t)at s)ould ,e amem,er of t)is rou. se.arated ,y commas

    hostgroup:members List of all ot)er )ostrou.s $)ose mem,ers s)ould also ,emem,ers of t)is rou. se.arated ,y commas

    O,ect Definitions

    Host Group Definition

  • 8/10/2019 Nagios Module 1

    96/123

    www.gnugroup.org 96

    4ost groups can also be used when defining services or dependencies."or e'a!ple,

    it is possible to tell Nagios that all 5inu' servers should have their ##4service !onitored and

    all 6I7 servers should have a telnet accepting connections.

    It is also possible to define dependencies between hosts They are, in a way, si!ilar to a parent+host relationship, butdependencies offer !ore co!ple' configuration options.

    Nagios will only issue host and service checs if all dependant hosts are

    currently up

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    97/123

    www.gnugroup.org 97

    Service Group Definition#ervices can be grouped in a si!ilar way to host ob8ects

    This can be done to !anage services !ore conveniently.

    It also aids in viewing service reports on the Nagios web interface.

    #ervice groups are also used to configure dependencies in a !oreconvenient way.

    O,ect Definitions

    Contact Definition

  • 8/10/2019 Nagios Module 1

    98/123

    www.gnugroup.org 98

    Contact Definition

    Contacts define people who can either be owners of specific !achines,or people who should be contacted in case of proble!s.

    epending on how your organi9ation chooses to contact people in caseof proble!s, the definition of a contact !ay vary a lot.

    6 contact consists of a uni:ue na!e, a descriptive na!e, and one or!ore e!ail addresses and;or pager nu!bers.

    Contact definitions can also contain additional data specific to how aperson can be contacted.

    O,ect Definitions

    Contact Definition

  • 8/10/2019 Nagios Module 1

    99/123

    www.gnugroup.org 99

  • 8/10/2019 Nagios Module 1

    100/123

    www.gnugroup.org 100

    Contacts can be grouped. Asually, grouping is used to eep a list ofwhich users are responsible for which tass,

    and the group !aps to 8ob responsibilities for particular people.

    It also !aes it possible to define people who should be responsible for handling proble!s at specific ti!e periods,

    and Nagios will auto!atically contact the right people depending on theti!e at which a proble! has occurred.

    It is also possible to specify different people or groups for handling host+related and service+related proble!sB

    for example, hardware ad!inistrators for handling host proble!s andsyste! ad!inistrators for handling service issues.

    O,ect Definitions

    Ti i d D fi iti

  • 8/10/2019 Nagios Module 1

    101/123

    www.gnugroup.org 101

    Time eriod Definition

    Ti!eperiod definitions allow you to control when variousaspects of the !onitoring and alerting logic can operate.

    "or instance, you can restrict

    When regularly scheduled host and service checs can beperfor!ed When notifications can be sent out When notification escalations can be used When dependencies are valid

    O,ect DefinitionsHow Time eriods !ork !ith Service Checks

    Without the i!ple!entation of ti!e periods, Nagios would !onitor all

  • 8/10/2019 Nagios Module 1

    102/123

    www.gnugroup.org 102

    services that you had defined / hours a day, 0 days a wee.

    While this is fine for !ost services that need !onitoring, it doesnDt worout so well for others.

    "or instance, do you really need to !onitor printers all the ti!e whentheyDre really only used during nor!al business hours?

    Eerhaps you have develop!ent servers which you would prefer to haveup, but arenDt -!ission critical- and therefore donDt have to be !onitoredfor proble!s over the weeend.

    Ti!e period definitions now allow you to have !ore control over whensuch services !ay be checed...

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    103/123

    www.gnugroup.org 103

    define time.eriodY time.eriodname admin1-oncall

    alias Admin1 On +all

    ;\->-1Z 0 1> 1/-;>/

    ;\->-1W 0 1> /-;>/

    ;\->-1\ 0 1> /-;>/

    ;\->-; 0 1> /-;>/

    ;\->-;1 0 1> /-;>/

    ;\->-;; 0 1> /-;>/

    ;\->-;7 0 1> /-;>/

    ;\->-;> 0 1> /-1/

    [

    define time.eriodY time.eriodname admin;-oncall

    alias Admin; On +all

    ;\->-;> 0 1> 1/-;>/

    ;\->-; 0 1> /-;>/

    ;\->-;6 0 1> /-;>/

    ;\->-;Z 0 1> /-;>/

    ;\->-;W 0 1> /-;>/

    ;\->-;\ 0 1> /-;>/

    ;\->-7 0 1> /-;>/

    ;\--1 0 1> /-1/

    [

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    104/123

    www.gnugroup.org 104

    Command Definition

  • 8/10/2019 Nagios Module 1

    105/123

    www.gnugroup.org 105

    #ervice dependencies wor in a si!ilar way as hostdependencies.

    "or services dependencies, you need to define a !asterservice and a dependent service

    "or e'a!ple,you can tell Nagios that E3E1 services on the e!ailservershost group depend on the 56E service on the ldapserverhost.

    O,ect Definitions

    Service Dependency Definition

  • 8/10/2019 Nagios Module 1

    106/123

    www.gnugroup.org 106

  • 8/10/2019 Nagios Module 1

    107/123

    www.gnugroup.org 107

    Host Dependency Definition

  • 8/10/2019 Nagios Module 1

    108/123

    www.gnugroup.org 108

    .erice Escalation 6einition

    Ser%ice escalations are com.letelyo.tional and are used to escalate

    notifications for a .articular ser%ice

    define ser%iceescalationY)ostname $e,ser%er

    ser%icedescri.tion H22#

    firstnotification 7

    lastnotification

    notificationinter%al \

    contactrou.s nt-adminsmanaers

    [

    define ser%iceescalationY

    )ostname

    $e,ser%er

    ;7>

    ser%icedescri.tion H22#

    firstnotification 6

    lastnotification 1

    notificationinter%al 6

    contactrou.s nt-adminsmanaerse%eryone

    [

    O,ect Definitions

  • 8/10/2019 Nagios Module 1

    109/123

    www.gnugroup.org 109

    Jost escalations 6einitionHost escalations are com.letelyo.tional and are used to escalatenotifications for a .articular )ost

    define )ostescalationY)ostname router-7>

    firstnotification

    lastnotification W

    notificationinter%al 6

    contactrou.s all-router-admins

    [

    define )ostescalationY

    )ostname router-7>

    firstnotification \

    lastnotification ;

    notificationinter%al 6contactrou.s all-net$or(-manaer

    [

    !unnin Naios

  • 8/10/2019 Nagios Module 1

    110/123

    www.gnugroup.org 110

    Starting and Stopping "agios

    Start "agios#$ %nit Script&

    The easiest way to start the Nagios dae!on is by using the init script lie

    so'etc'rc(d'init(d'nagios start

    )$ *anually& Hou can start the Nagios dae!on !anually with the +dco!!and line option lie so'usr'local'nagios'+in'nagios ,d 'usr'local'nagios'etc'nagios(cfg

    !unnin Naios

    Starting and Stopping "agios

    -estarting "agios

  • 8/10/2019 Nagios Module 1

    111/123

    www.gnugroup.org 111

    -estarting "agios2estarting;reloading is nececessary when you !odify your configuration

    files and want those changes to tae effect.

    #$ %nit Script&The easiest way to restart the Nagios dae!on is by usingthe init script lie so ;etc;rc.d;init.d;nagios reload

    )$ !e+ %nterface&Hou can restart the Nagios through the webinterface by clicing the -Erocess Info-navigation lin andselecting -2estart the Nagios process-

    !unnin NaiosStarting and Stopping "agios

    Stopping "agios

    #$ %nit Script&he easiest way to stop the Nagios dae!on is by using the

  • 8/10/2019 Nagios Module 1

    112/123

    www.gnugroup.org 112

    init script lie so ;etc;rc.d;init.d;nagios stop

    )$ !e+ %nterface& Hou can stop the Nagios through the web interfaceby clicing the -Erocess Info- navigation lin and selecting -#hutdownthe Nagios process-

    .$ *anually&Hou can stop the Nagios process by sending it a #IT

  • 8/10/2019 Nagios Module 1

    113/123

    www.gnugroup.org 113

    1 2)e )ost )as c)aned its state to DO*N or UN!EA+HA&LE stateR notificationis sent out after firstnotificationdelay num,er of minutes s.ecified int)e corres.ondin )ost o,ect

    ;2)e )ost remains in DO*N or UN!EA+HA&LE stateR notification is sent oute%ery notificationinter%al num,er of minutes s.ecified in t)e corres.ondin

    )ost o,ect 7 Host reco%ers to an U# stateR notification is sent out immediately and only once

    >Host starts or sto.s fla..inR notification is sent out immediately

    Host remains fla..inR notification is sent out e%ery notificationinter%al num,er

    of minutes s.ecified in t)e corres.ondin )ost o,ect

    Notifications

    Notiications ma# be sent out in one o the ollo&ing situations%

    6 Ser%ice )as c)aned its state to *A!NING +!I2I+AL or UNNO*N stateR notification is sent out after first notification delay num,er of minutes s.ecified in

  • 8/10/2019 Nagios Module 1

    114/123

    www.gnugroup.org 114

    notification is sent out after firstnotificationdelay num,er of minutes s.ecified int)e corres.ondin ser%ice o,ect

    Z Ser%ice remains in *A!NING +!I2I+AL or UNNO*N stateR notification issent out e%ery notificationinter%al num,er of minutes s.ecified in t)ecorres.ondin ser%ice o,ect

    W Ser%ice reco%ers to an O stateR notification is sent out immediatelyand only once

    \ Ser%ice starts or sto.s fla..inR notification is sent out immediately

    1 Ser%ice remains fla..inR notification is sent out e%ery notificationinter%al num,er of minutes s.ecified in t)e corres.ondin ser%ice o,ect

    If one of t)ese conditions occurs Naios starts e%aluatin $)et)er informationa,out it s)ould ,e sent out and to $)om

    Notifications

    *)o Gets Notifiedb

  • 8/10/2019 Nagios Module 1

    115/123

    www.gnugroup.org 115

    Eac) )ost and ser%ice definition )as a contactrou.sK o.tion t)at s.ecifies $)atcontact rou.s recei%e notifications for t)at .articular )ost or ser%ice

    +ontact rou.s can contain one or more indi%idual contacts

    Notiication ethods

    .aer+ell.)oneemailinstant messaeaudio alertetc

    Host +)ec(s

    *)en Are Host +)ec(s #erformedb

  • 8/10/2019 Nagios Module 1

    116/123

    www.gnugroup.org 116

    Hosts are c)ec(ed ,y t)e Naios daemon/At reular inter%als as defined ,y t)e c)ec(inter%al and retryinter%al o.tions inyour )ost definitions

    On-demand $)en a ser%ice associated $it) t)e )ost c)anes state

    On-demand as needed as .art of t)e )ost reac)a,ility loic

    On-demand as needed for .redicti%e )ost de.endency c)ec(s

    Ser%ice +)ec(s

    *)en Are Ser%ice +)ec(s #erformedb

  • 8/10/2019 Nagios Module 1

    117/123

    www.gnugroup.org 117

    Ser%ices are c)ec(ed ,y t)e Naios daemon/At reular inter%als as defined ,y t)e c)ec(inter%al and retryinter%al o.tions inyour ser%ice definitions

    On-demand as needed for .redicti%e ser%ice de.endency c)ec(s

    Acti%e +)ec(s

  • 8/10/2019 Nagios Module 1

    118/123

    www.gnugroup.org 118

    Naios is ca.a,le of monitorin )osts and ser%ices in t&o &a#s%actiel# and passiel#

    Acti%e c)ec(s are t)e most common met)od for monitorin )ostsand ser%ices 2)e main features of acti%es c)ec(s as as follo$s/

    Acti%e c)ec(s are initiated ,y t)e Naios .rocess

    Acti%e c)ec(s are run on a reularly sc)eduled ,asis

    Jo& *re *ctie Chec$s -erormed1

    Acti%e c)ec(s are initiated ,y t)e c)ec( loic in t)e Naios daemon

    *)en Naios needs to c)ec( t)e status of a )ost or ser%ice it $illexecute a .luin and .ass it information a,out $)at needs to ,ec)ec(ed

    2)e .luin $ill t)en c)ec( t)e o.erational state of t)e )ost or ser%iceand re.ort t)e results ,ac( to t)e Naios daemon

    Naios $ill .rocess t)e results of t)e )ost or ser%ice c)ec( and ta(ea..ro.riate action as necessary 3e send notifications run e%ent

    )andlers etc5

    #assi%e +)ec(s

  • 8/10/2019 Nagios Module 1

    119/123

    www.gnugroup.org 119

    State 2y.esJost .tates Hosts t)at are c)ec(ed can ,e in one of t)ree different states/

    U#

  • 8/10/2019 Nagios Module 1

    120/123

    www.gnugroup.org 120

    DO*N

    UN!EA+HA&LE

    Jost .tate 6eterminationHost c)ec(s are .erformed ,y .luins $)ic) can return a state of

    O

    *A!NING

    UNNO*N or

    +!I2I+AL

    State 2y.esJost .tates#luin !esult #reliminary Host State

    O U#

  • 8/10/2019 Nagios Module 1

    121/123

    www.gnugroup.org 121

    *A!NING U# or DO*N

    UNNO*N DO*N

    +!I2I+AL DO*N

    #reliminary Host State #arent Host State Cinal Host State

    DO*N At least one .arent is U# DO*N

    DO*N All .arents are eit)er UN!EA+HA&LE

    DO*N or UN!EA+HA&LE

    State 2y.esJost .tate Changes.ot .tates

    .ot states occur in the ollo&ing situations

  • 8/10/2019 Nagios Module 1

    122/123

    www.gnugroup.org 122

    15 *)en a ser%ice or )ost c)ec( results in a non-O or non-U# state and t)eser%ice c)ec( )as not yet ,een 3re5c)ec(ed t)e num,er of times s.ecified ,y t)emaxc)ec(attem.ts directi%e in t)e ser%ice or )ost definition 2)is is called asoft error

    ;5 *)en a ser%ice or )ost reco%ers from a soft error 2)is is considered a soft reco%ery

    2he ollo&ing things occur &hen hosts or serices experience .4F2 statechanges%

    2)e SOC2 state is loed

    E%ent )andlers are executed to )andle t)e SOC2 state

    2)e only im.ortant t)in t)at really )a..ens durin a soft state is t)e execution ofe%ent )andlers

    Usin e%ent )andlers can ,e .articularly useful if you $ant to try and .roacti%ely fix a.ro,lem ,efore it turns into a HA!D state

    State 2y.esJost .tate ChangesJard .tates

    Jard states occur or serices in the ollo&ing situations

  • 8/10/2019 Nagios Module 1

    123/123

    www.gnugroup.org 123

    15 *)en a ser%ice c)ec( results in a non-O state and it )as ,een 3re5c)ec(ed t)enum,er of times s.ecified ,y t)e maxc)ec(attem.tsK o.tion in t)e ser%icedefinition 2)is is a )ard error state

    ;5 *)en a ser%ice reco%ers from a )ard error state 2)is is considered to ,e a )ard

    !eco%ery75 *)en a ser%ice c)ec( results in a non-O state and its corres.ondin )ost is eit)er

    DO*N or UN!EA+HA&LE

    &hat happens &hen a host or serice is in a hard state%

    )anes from a )ard O state to a )ard non-O state

    c)anes from a )ard non-O state to a )ard O-state

    c)anes from a )ard non-O state of some (ind to a )ard non-O state ofanot)er (ind