Nagios Module 2

Embed Size (px)

Citation preview

  • 8/10/2019 Nagios Module 2

    1/58

    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 2

    2/58

    www.gnugroup.org 2

    NAGIOS

    MODULE - 2

  • 8/10/2019 Nagios Module 2

    3/58

    www.gnugroup.org 3

    Index of module - 2

    External Commands

    Event Handlers

    Volatle Serv!es

    "res#ness C#e!$s

    State Stal$n%

    "la&&n%

    Usn% 'em&lates

    O(e!t In#ertan!e

    )assve C#e!$ *NSCA Clustern% - Dstr+uted

    Montorn%

    ,edundant and "aloverNetor$ Montorn%

    Na%os.L

    Se!urt/ Consderatons

  • 8/10/2019 Nagios Module 2

    4/58

    www.gnugroup.org 4

    External Commands

    Na%os !an &ro!ess !ommandsfrom external a&&l!atons0n!ludn% t#e CGIs1 and altervarous as&e!ts of ts montorn%fun!tons +ased on t#e !ommandst re!eves

    External a&&l!atons !an su+mt!ommands +/ rtn% to t#e!ommand fle3 #!# s&erod!all/ &ro!essed +/ t#e

    Na%os daemon

  • 8/10/2019 Nagios Module 2

    5/58

    www.gnugroup.org 5

    External CommandsEnabling External Commands

    In order to #ave Na%os &ro!ess external !ommands3 ma$e sure /ou do t#e follon%4

    Ena+le external !ommand !#e!$n% t# t#e !#e!$5external5!ommands o&ton

    Set t#e fre6uen!/ of !ommand !#e!$s t# t#e !ommand5!#e!$5nterval o&ton

    S&e!f/ t#e lo!aton of t#e !ommand fle t# t#e !ommand5fle o&ton

    Setu& &ro&er &ermssons on t#e dre!tor/ !ontann% t#e external !ommand fle3 as des!r+ed n t#e 6u!$start%ude

    When Does Nagios Check For External Commands

    At re%ular ntervals s&e!fed +/ t#e !ommand5!#e!$5nterval o&ton n t#e man !onf%uraton fle

    Immedatel/ after event #andlers are exe!uted '#s s n addton to t#e re%ular !/!le of external !ommand !#e!$sand s done to &rovde mmedate a!ton f an event #andler su+mts !ommands to Na%os

    Using External Commands

    External !ommands !an +e used to a!!om&ls# a varet/ of t#n%s #le Na%os s runnn% Exam&le of #at !an +e done n!lude tem&orarl/ dsa+ln% notf!atons for serv!es and #osts3 tem&orarl/

    dsa+ln% serv!e !#e!$s3 for!n% mmedate serv!e !#e!$s3 addn% !omments to #osts and serv!es3 et!

  • 8/10/2019 Nagios Module 2

    6/58

    www.gnugroup.org 6

    Event HandlersEvent #andlers are o&tonal s/stem !ommands 0s!r&ts or exe!uta+les1 t#at are run #enever a#ost or serv!e state !#an%e o!!urs

    An o+vous use for event #andlers s t#e a+lt/ for Na%os to &roa!tvel/ fx &ro+lems +efore an/ones notfed Some ot#er uses for event #andlers n!lude4

    ,estartn% a faled serv!e

    Entern% a trou+le t!$et nto a #el&des$ s/stem

    Lo%%n% event nformaton to a data+ase

    Et!

    7#en Are Event Handlers Exe!uted8

    Event #andlers are exe!uted #en a serv!e or #ost4

    Is n a SO"' &ro+lem state

    Intall/ %oes nto a HA,D &ro+lem state

    Intall/ re!overs from a SO"' or HA,D &ro+lem state

  • 8/10/2019 Nagios Module 2

    7/58

    www.gnugroup.org 7

    Event Handlers E!ent "andler #$pes

    '#ere are dfferent t/&es of o&tonal event #andlers t#at /ou !an defne to #andle #ost and state !#an%es4

    Glo+al #ost event #andler

    Glo+al serv!e event #andler

    Host-s&e!f! event #andlers

    Serv!e-s&e!f! event #andlers

    Enabling E!ent "andlersEvent #andlers !an +e ena+led or dsa+led on a &ro%ram-de +ass +/ usn% t#e ena+le5event5#andlers

    n /our man !onf%uraton fle

    Host- and serv!e-s&e!f! event #andlers !an +e ena+led or dsa+led +/ usn% t#e event5#andler5ena+led

    dre!tve n /our #ost and serv!e defntons

    Host- and serv!e-s&e!f! event #andlers ll not +eexe!uted f t#e %lo+al ena+le5event5#andlers o&ton s dsa+led

  • 8/10/2019 Nagios Module 2

    8/58

    www.gnugroup.org 8

    Event HandlersExample o% E!ent "andlers

    "ost %ile directi!edefne serv!e9

    use lo!al-serv!e

    #ost5name lo!al#ost

    serv!e5des!r&ton daemons

    !#e!$5!ommand !#e!$5nr&e:!#e!$5daemons

    event5#andler restart&ser!ices

    ;In $our commands'c%g %ile( make sure $ou ha!e e!ent)handler de%ined something like*

    defne !ommand9

    !ommand5name restart&ser!ices

    !ommand5lne *usr*lo!al*na%os*l+exe!*event#andlers*restart-serv!es ou sm&l/defne t#e tem&late as t#e re6uredo+(e!t t/&e '#e onl/ dfferen!e s t#at /ouneedto s&e!f/ t#e register directi!e andspeci%$ a !alue( o% :for t '#s ll tellNa%ost#at t s#ould not treat t#s as an a!tualo+(e!t3 +ut as a tem&late

    defne someo+(e!tt/&e9o+(e!t-s&e!f! vara+les name template)nameuse name)o%)template)to)useregister A:/;B;

  • 8/10/2019 Nagios Module 2

    24/58

    www.gnugroup.org 24

    O+(e!t In#ertan!e Fas!s

    '#ere are three !ariables a%%ecting recursionand inheritancet#at are &resent n all o+(e!tdefntons

    #he %irst !ariable is name' Its (ust a ?tem&late?name t#at !an +e referen!ed n ot#er o+(e!tdefntons so t#e/ !an n#ert t#e o+(e!ts&ro&ertes*vara+les 'em&late names must +e

    un6ue amon%st o+(e!ts of t#e same t/&e3

    #he second !ariable is use''#s s #ere /ous&e!f/ t#e name of t#e tem&late o+(e!t t#at /ouant to n#ert &ro&ertes*vara+les from '#ename /ou s&e!f/ for t#s vara+le must +edefned as anot#ero+(e!tBs tem&late named0usn% t#e name vara+le1

    #he #hird( -egister( Defnn% tem&lates nNa%os s ver/ smlar to defnn% a!tual o+(e!ts>ou sm&l/defne t#e tem&late as t#e re6uredo+(e!t t/&e '#e onl/ dfferen!e s t#at /ouneedto s&e!f/ t#e register directi!e andspeci%$ a !alue( o% :for t '#s ll tellNa%ost#at t s#ould not treat t#s as an a!tualo+(e!t3 +ut as a tem&late

    defne someo+(e!tt/&e9o+(e!t-s&e!f! vara+les name template)nameuse name)o%)template)to)useregister A:/;B;

  • 8/10/2019 Nagios Module 2

    25/58

    www.gnugroup.org 25

    O+(e!t In#ertan!e

  • 8/10/2019 Nagios Module 2

    26/58

    www.gnugroup.org 26

    )assve C#e!$ * NSCA

    Anot#er %reat feature t#at Na%os offers s t#e a+lt/ for t#rd-&art/ softare orot#er Na%os nstan!es to re&ort nformaton on t#e status of serv!es or #osts

    '#s a/3 Na%os does not need to s!#edule and run !#e!$s +/ tself3 +ut ot#era&&l!atons !an re&ort nformaton ast s avala+le to t#em

    '#s means t#at /our a&&l!atons !an send &ro+lem re&orts dre!tl/ to Na%osnstead of (ust lo%%n% t#em

    Na%os also offers a tool for sendn% &assve !#e!$ results for #osts and serv!esover a netor$ It s !alled NSCA 0Na%os Serv!e C#e!$ A!!e&tor1

    It !an +e used to send results from one Na%os nstan!e to anot#er

    '#s me!#ansm n!ludes &assord &rote!ton3 alon% t# en!r/&ton3 to&reventn(e!ton of false results n to Na%os In t#s a/3 NSCA !ommun!aton sentover Internet s more se!ure

  • 8/10/2019 Nagios Module 2

    27/58

    www.gnugroup.org 27

    )assve C#e!$ * NSCA

    '#ere are also dfferent t/&es of !#e!$s n!ludn% external a&&l!atons or dev!est#at ant to re&ort nformaton dre!tl/ to Na%os

    '#s !an +e done to %at#er all !rt!al errors to a sn%le3 !entral &la!e '#ese t/&esof !#e!$s are !alled )assve C#e!$s

    "or exam&le3 #en a e+ a&&l!aton !annot !onne!t to t#e data+ase3 t ll letNa%os $no a+out t mmedatel/

    It !an also send re&orts after a data+ase re!over/3 or &erod!all/3 even f!onne!tvt/ to t#e data+ase #as +een !onsstentl/ avala+le3 so t#at Na%os #as anu&-to-date status

    '#s !an +e done n addton to a!tve !#e!$s3to dentf/ !rt!al &ro+lems earler

    Na%os also offers a a/ of !om+nn% t#e +enefts of +ot# a!tve and &assve!#e!$s

  • 8/10/2019 Nagios Module 2

    28/58

    www.gnugroup.org 28

    )assve C#e!$ * NSCA

    '#e frst t#n% t#at needs to +e done n order to use &assve !#e!$s for /our Na%ossetu& s to ma$e sure t#at /ou #ave t#e follon% o&tons n /our man Na%os!onf%uraton fle4

    accept)passi!e)ser!ice)checks1;

    accept)passi!e)host)checks1;

    It ould also +e %ood to ena+le t#e lo%%n% of n!omn% &assve !#e!$s

    '#s ma$es determnn% t#e &ro+lem of not &ro!essn% a &assve !#e!$ mu!#easer '#e follon% dre!tve allos t4

    log)passi!e)checks1;

  • 8/10/2019 Nagios Module 2

    29/58

    www.gnugroup.org 29

    )assve C#e!$ * NSCA +etting up hosts or ser!ices %or passi!e

    checking re4uires an ob@ect to bede%ined and set u& so as not to &erforma!tve !#e!$s

    defne #ost

    9

    Use %ener!-#ost

    #ost5name ln+ox

    Address

    active_checks_enable !

    &assve5!#e!$s5ena+led

    ;

    Con%iguring ser!ices is exactl$ thesame as 6ith hosts

    defne serv!e

    9

    Use &n%-tem&late #ost5name ln+ox

    serv!e5des!r&ton )ING

    acti!e)checks)enabled :

    &assve5!#e!$s5ena+led

    ;

    In t#s !ase3 Na%os ll never &erform an/ a!tve !#e!$s on ts on and ll onl/rel/ on t#e results t#at are &assed to t

    7e !an also !onf%ure Na%os so t#at f no ne nformaton #as +een &rovdedt#n a !ertan &erod of tme3 t ll use a!tve !#e!$s to %et t#e !urrent status oft#e #ost or serv!e b$ setting the acti!e)checks)enabled option to ;

  • 8/10/2019 Nagios Module 2

    30/58

    www.gnugroup.org 30

    NSCA

    NSCA s an a&&l!aton t#at allos t#e sendn% of results dre!tl/ to t#eNa%osexternal !ommand &&e

    NSCA !onssts of to &artst#e server and t#e !lent

    '#e &art res&ons+le for re!evn% !#e!$ results and &assn% t#em to Na%os s t#e

    server '#s lstens on a s&e!f! 'C) &ort for NSCA !lents &assn% nformaton

    It a!!e&ts and aut#ent!ates n!omn% !onne!tons and &asses t#ese results to t#eNa%os external !ommand &&e

    All nformaton s en!r/&ted usn% t#e MCr/&t l+rar/

  • 8/10/2019 Nagios Module 2

    31/58

    www.gnugroup.org 31

    NSCA

  • 8/10/2019 Nagios Module 2

    32/58

    www.gnugroup.org 32

    NSCA

  • 8/10/2019 Nagios Module 2

    33/58

    www.gnugroup.org 33

    NSCA

  • 8/10/2019 Nagios Module 2

    34/58

    www.gnugroup.org 34

    NSCA

    NSCA s an a&&l!aton t#at allos t#e sendn% of results dre!tl/ to t#eNa%osexternal !ommand &&e

    NSCA !onssts of to &artst#e server and t#e !lent

    '#e &art res&ons+le for re!evn% !#e!$ results and &assn% t#em to Na%os s t#e

    server '#s lstens on a s&e!f! 'C) &ort for NSCA !lents &assn% nformaton

    It a!!e&ts and aut#ent!ates n!omn% !onne!tons and &asses t#ese results to t#eNa%os external !ommand &&e

    All nformaton s en!r/&ted usn% t#e MCr/&t l+rar/

  • 8/10/2019 Nagios Module 2

    35/58

    www.gnugroup.org 35

    Clustern%

    One of t#e frst +ottlene!$s or%anatons ll run nto s &erforman!e #enmontorn% a lar%e num+er of #osts and serv!es

    '#s !an o!!ur even earler f /ou are usn% &erforman!e #andlers on /our serv!eor #ost !#e!$s

    One a/ to resolve &erforman!e &ro+lems s to !luster Na%os

    !lustern% s also ver/ useful #en t#ere are a num+er of remote stes t#at need to+e montored +/ Na%os

    Usuall/3 t#ere are one or more Na%os nstan!es t#at re&ort nformaton to a sn%le!entral Na%os nstan!e

    '#e servers t#at re&orts nformaton to anot#er Na%os ma!#ne as a slave

    A Na%os nstan!e t#at re!eves re&orts from oneor more slaves ll +e referred toas a master

  • 8/10/2019 Nagios Module 2

    36/58

    36

    One Na%os Instan!e

  • 8/10/2019 Nagios Module 2

    37/58

    www.gnugroup.org 37

    Clustern%

    One of t#e frst +ottlene!$s or%anatons ll run nto s &erforman!e #enmontorn% a lar%e num+er of #osts and serv!es

    '#s !an o!!ur even earler f /ou are usn% &erforman!e #andlers on /our serv!eor #ost !#e!$s

    One a/ to resolve &erforman!e &ro+lems s to !luster Na%os

    !lustern% s also ver/ useful #en t#ere are a num+er of remote stes t#at need to+e montored +/ Na%os

    Usuall/3 t#ere are one or more Na%os nstan!es t#at re&ort nformaton to a sn%le!entral Na%os nstan!e

    '#e servers t#at re&orts nformaton to anot#er Na%os ma!#ne as a slave

    A Na%os nstan!e t#at re!eves re&orts from oneor more slaves ll +e referred toas a master

  • 8/10/2019 Nagios Module 2

    38/58

    38

    Man/ Na%os Instan!es

  • 8/10/2019 Nagios Module 2

    39/58

    www.gnugroup.org 39

    Clustern%

  • 8/10/2019 Nagios Module 2

    40/58

    www.gnugroup.org 40

    Clustern%

    Data "lo

  • 8/10/2019 Nagios Module 2

    41/58

    www.gnugroup.org 41

    Clustern%

  • 8/10/2019 Nagios Module 2

    42/58

    www.gnugroup.org 42

    Clustern% remote site Con%iguration

    nstall Na%os as normal on t#e server and t#en !#an%e t#e follon% &arameters nna%os!f% to allo t to fun!ton &ro&erl/ n our Na%os !luster4

    enable)noti%ications 1 : J 7e do not ant t#s nstan!e sendn% out

    notf!atons

    obsess)o!er)ser!ices1; J 7e ant t#e remote server to o+sess over

    serv!es so all !#an%es ll +e re&orted +a!$ to t#e master server

    oscp)command1nsca)send)result J '#s s a !ustom s!r&t s#on next

    7t# t#ese !onf%uraton !#an%es n &la!e3 t#e remote Na%os server ll !all t#e!ommand ns!a5send5result after ever/ serv!e !#e!$ exe!uted on t#e remote#ost

    '#e ns!a5send5result s!r&t ll t#en forard t#e serv!e !#e!$ results to t#emaster Na%os server

    l

  • 8/10/2019 Nagios Module 2

    43/58

    www.gnugroup.org 43

    Clustern% '#e ns!a5send5result s!r&t ll t#en forard t#e serv!e !#e!$ results to t#e

    master Na%os server )la!e t#e follon% defnton for ns!a5send5result n /our

    !ommands

    !onf%uraton fle 0!ommands!f% +/ default14

    de%ine command

    command)name nsca)send)result

    command)line /usr/local/nagios/libexec/nsca)send)result",+#N02E +E-=ICEDE+C< +E-=ICE+#0#E+E-=ICE,U#5U#