Christian Benvenuti - PERiiperi.net.ni/pdf/docAdmOptAB/06_Nagios.pdf · check_command...

Preview:

Citation preview

Optimisacion del ancho de bandaMonitoreo/Nagios

Christian Benvenutichristian.benvenuti@libero.it

Managua, Nicaragua, 1-5/3/2010

UNAN-Managua

Before we start ...

● Have you ever used Nagios?● Have you ever installed Nagios?

● How? (tarball or via GUI)● If yes, can you remember any specific problem you

had to resolve?

● What kind of monitoring information can Nagios provide? (examples)

● What kind of monitoring information can't Nagios provide? (examples)

Schedule● Introduction to the class of network monitoring

features provided by Nagios● Architectural overview: object types and

relationships, etc● Overview of basic features and examples of

configurations● Overview of more advanced features and

examples of configurations● Installation and basic configuration● Exercises

Basic Features● Object types and relationships

● Hosts vs Services● Host groups, Service groups

● Contacts and notifications● Contact groups, escalations

● Templates● Object Dependencies● Templates and Object Inheritance● Passive checks and NCSA (quick intro)● Management (Web Interface)

I know thisalready (Y/N)

Advanced features

● Nagios Check Service Acceptor (NCSA)● Remote monitoring

● Nagios Remote Plugin Executor (NRPE)● Simple Network Management Protocol (SNMP)

I know thisalready

Probably tomorrow, together with MRTG & Cacti

OPTIONAL(time permitting)

Functionalities Overview● What do we want/need to monitor?● What do we want/need to do with the information

returned by the monitoring process?● What if a host is down?● What if the web server is UP (=reachable) but not

working properly?

● How would the organization of the monitoring configuration change when applied to a big network?● Scalability● Easiness of upgrade/troubleshooting● etc

Example

Nagios

Internet

WWW Mail

...

PC1 PCn

...

Admin1

Admin2

Suporte tecnico

...

DHCP

How would I write (in plain English orSpanish) the monitoring rules/configthat would simplify the admin's life?

Object types

● Monitored object types:● Hosts (routers, switches, servers, ...)● Services (www, dhcp, ftp, ssh, ...)● Derived monitored object types

– Host groups– Service groups

● Xxx object types:● Contacts and Contact Groups● Time periods● Commands

Host vs Service

Nagios

Internet

WWW Mail

...

PC1 PCn

...

Admin1

Admin2

Suporte tecnico

...

DHCP

Is this ahost or a service?

What is this?

And this?

What's the difference between hosts and services?

TCP/IP stack

Applications

WE

B s

erve

r

Em

ail s

erve

r

DN

S s

erve

r

...

host

services

This rule does not apply always.Example?

SS

HD

ser

ver

Object type: host

define host {

host_name default_gw

alias default gateway

address 10.0.1.1

...

}

10.0.1.1/24

10.0.1.100/24

NagiosInternet

gw.mynet.edu

Object type: host

define host {

}

host_name default_gwalias default_gatewayaddress 10.0.1.1...

... check parameters ...

... contact/notificationparameters ...

check_commandcheck_intervalretry_intervalmax_check_attemptscheck_period

Object type: host

define host {

}

host_name default_gwalias default_gatewayaddress 10.0.1.1...

... check parameters ...

... contact/notificationparameters ...

contactscontact_groupsfirst_notification_delaynotification_intervalnotification_periodnotification_options

Object type: hostExample

define host {

host_name default_gw

alias default gateway

address 10.0.1.1

check_command check-host-alive

check_interval 5

retry_interval 1

max_check_attempts 5

check_period 24x7

contacts admin@xxxuniv.edu.ni

notification_interval 60

notification_period 24x7

notification_options d,u,r

}

Object type: hostExample

define host {

host_name default_gw

alias default gateway

address 10.0.1.1

check_command check-host-alive

check_interval 5

retry_interval 1

max_check_attempts 5

check_period 24x7

contacts admin@xxxuniv.edu.ni

notification_interval 60

notification_period 24x7

notification_options d,u,r

}

define host { host_name router_eng alias Router for the Engineering campus address 10.0.1.1 ...}define host { host_name router_law alias Router for the Law campus address 10.0.2.1 ...}define host { host_name router_art alias Router for the Art campus address 10.0.3.1 ...}

Eng

Law

Art

10.0.1.2

10.0.1.3

10.0.1.4

Nagios

Internet

10.0.1.1

Nagios

Nagios

define host { host_name router_eng alias Router for the Engineering campus address 10.0.1.1 ...}define host { host_name router_law alias Router for the Law campus address 10.0.2.1 ...}define host { host_name router_art alias Router for the Art campus address 10.0.3.1 ...}

Eng

Law

Art

10.0.1.2

10.0.1.3

10.0.1.4

Internet

10.0.1.1

Nagios

define host {

host_name router_eng

alias Router for the Engineering campus

address 10.0.1.1

...

}

define host {

host_name router_law

alias Router for the Law campus

address 10.0.1.2

...

}

define host {

host_name router_art

alias Router for the Art campus

address 10.0.1.3

...

}

define hostgroup {

hostgroup_name campus_routers

alias All the routers that connect the university campuses

members router_art, router_law, router_eng

}

Object type: hostgroup

define host { host_name router_eng alias Router for the Engineering campus address 10.0.1.1 ...}define host { host_name router_law alias Router for the Law campus address 10.0.2.1 ...}define host { host_name router_art alias Router for the Art campus address 10.0.3.1 ...}

Eng

Law

Art

10.0.1.2

10.0.1.3

10.0.1.4

Internet

10.0.1.1

Nagios

define host {

host_name router_eng

alias Router for the Engineering campus

address 10.0.1.2

...

}

define host {

host_name router_law

alias Router for the Law campus

address 10.0.1.3

...

}

define host {

host_name router_art

alias Router for the Art campus

address 10.0.1.4

...

}

define hostgroup {

hostgroup_name campus_routers

alias All the routers that connect the university campuses

members 10.0.2.1, 10.0.3.1, 10.0.4.1

}

Is this config correct?

define host { host_name router_eng alias Router for the Engineering campus address 10.0.1.1 ...}define host { host_name router_law alias Router for the Law campus address 10.0.2.1 ...}define host { host_name router_art alias Router for the Art campus address 10.0.3.1 ...}

Eng

Law

Art

10.0.1.2

10.0.1.3

10.0.1.4

Internet

10.0.1.1

Nagios

define host {

host_name router_eng

alias Router for the Engineering campus

address 10.0.2.1

...

}

define host {

host_name router_law

alias Router for the Law campus

address 10.0.3.1

...

}

define host {

host_name router_art

alias Router for the Art campus

address 10.0.4.1

...

}

define hostgroup {

hostgroup_name campus_routers

alias All the routers that connect the university campuses

members router_eng, router_law, router_art

}

Is this config correct?

define host { host_name router_eng alias Router for the Engineering campus address 10.0.1.1 ...}define host { host_name router_law alias Router for the Law campus address 10.0.2.1 ...}define host { host_name router_art alias Router for the Art campus address 10.0.3.1 ...}

Eng

Law

Art

10.0.1.2

10.0.1.3

10.0.1.4

Internet

10.0.1.1

Nagios

define host {

host_name router_eng

alias Router for the Engineering campus

address 10.0.1.2

...

}

define host {

host_name router_law

alias Router for the Law campus

address 10.0.1.3

...

}

define host {

host_name router_art

alias Router for the Art campus

address 10.0.1.4

...

}

define hostgroup {

hostgroup_name campus_routers

alias All the routers that connect the university campuses

members router_eng, router_law, router_art

}

Is this config correct?

define host { host_name router_eng alias Router for the Engineering campus address 10.0.1.1 ...}define host { host_name router_law alias Router for the Law campus address 10.0.2.1 ...}define host { host_name router_art alias Router for the Art campus address 10.0.3.1 ...}

Eng

Law

Art

10.0.1.2

10.0.1.3

10.0.1.4

Internet

10.0.1.1

Nagios

define host {

host_name router_eng

alias Router for the Engineering campus

address 10.0.1.2

...

}

define host {

host_name router_law

alias Router for the Law campus

address 10.0.1.3

...

}

define host {

host_name router_art

alias Router for the Art campus

address 10.0.1.4

...

}

define hostgroup {

hostgroup_name campus_routers

alias All the routers that connect the university campuses

Members router_eng, router_law, router_art

}

Is this config correct?

Examples of Host Groups

hostgroup windows_lab hostgroup linux_lab

Examples of Host Groups

hostgroup servidores_web hostgroup servidores_correo

WEB Correo WEB Correo

Campus A Campus B

... ...

Hosts vs Services

WEB Correo

Campus A

...

Nagios

10.0.1.100 10.0.1.101

define host { host_name Campus_A_WEB alias Servidor Web Campus A address 10.0.1.100 check_command check_host_alive ...}define host { host_name Campus_A_CORREO alias Servideor Correo Campus A address 10.0.1.101 check_command check_host_alive ...}

Is this sufficient to monitor the two Web/Mail servers?

Object type: servicedefine host { host_name web_server alias WEB server address 10.0.1.100 ...}

define service { host_name web_server , ... service_description WEB server check_command check_http ...}

Nagios

Internet

10.0.1.100

WWW

...

...

Object type: service

define service {

}

host_name default_gwalias default_gatewayaddress 10.0.1.1...

... check parameters ...

... contact/notificationparameters ...

check_commandcheck_intervalretry_intervalmax_check_attemptscheck_period

Hosts vs Services

define host {

}

host_name alias address ...

... check parameters ...(check_command, etc)

... contact/notificationparameters ...(contacts, etc)

host_name service_description...

... check parameters ...(check_command, etc)

... contact/notificationparameters ...(contacts, etc)

define service {

}

Object type: servicegroup

define servicegroup {

servicegroup_name web_servers

alias todos los servidores we

members host1,service1, host2,service2, ...

...

}

Example of service group

define host {

host_name www_unan_managua

alias UNAN Managua web server

address www.unan.edu.ni

...

}

define host {

host_name ftp_unan_leon

alias UNAN Managua ftp server

address ftp.unan.edu.ni

...

}

define servicet {

host_name www_unan_managua

service_description www

check_command check_http

...

}

define service {

host_name ftp_unan_managua

service_description ftp

check_command check_ftp

...

}

define service_group {

servicegroup_name services_unan_managua

alias servicios publicos ofrecidos por UNAN Managua

members www_unan_managua,www, ftp_unan_managua,ftp

...

}

Plugins:parameter check_command

● Host plugins● check_host_alive

● Service plugins● check_http● check_dns● check_dhcp● ...

Object type: (check) commands

define command {

command_name .........

command_line .........

}

Example from /etc/nagios/objects/commands.cfg:

define command { command_name check_http command_line $USER1$/check_http -I \ $HOSTADDRESS$ $ARG1$ }

Object type: (check) commands

define command { command_name check_http command_line $USER1$/check_http -I \ $HOSTADDRESS$ $ARG1$ }

USER MACRO(See resources.cfg)

Pre-defines MACROs

Is this a chicken-egg problem?

There are other typesof macro too (see

on-demand macros)

Notifications

Contacts Notifications

What? When? How?

Notifications

● When there is a problem● Do you think the more people receive a notification

and the better it is?● Do you think an email is sufficient to tell/notify the

owner of a service/host about a problem?● How do you handle cases where it is not clear who

the best contact person/s is/are?– This may not be an issue when there is lack of personal

and everybody takes care of everything. Does this sound like a familiar situation to you :-) ?

Notifications

InstantMessaging

Pager

SMS

Email

How good are emailsfor urgent problems?

Are these a good option fornotifications generated duringthe night?

It depends!

NotificationsEscalations

Nagios

Internet

10.0.1.100

WWW

X

...

Escalation

Parameters check_period and notification_period

● check_period● Name of the time period during which Nagios

should check the host/service status.● notification_period

● Name of the time period during which Nagios should generate notifications if necessary (according to the config).

● Same syntax (= object timeperiod)

define timeperiod { timeperiod_name <name> alias <description> ... } See file /etc/nagios/objects/timeperiods.cfg in FC12 for a few examples.

Object type: contact

define contact {

}

contact_name Benvealias Christian Benvenuti

... HOST notificationparameters ...

... SERVICE notificationparameters ...

... addresses ...

... etc ...

Object type: contact

define contact {

}

contact_name Benvealias Christian Benvenuti

... HOST notificationparameters ...

... SERVICE notificationparameters ...

emailpageraddress1address2...address6

... addresses ...

... etc ...

Object type: contact

define contact {

}

contact_name Benvealias Christian Benvenuti

... HOST notificationparameters ...

... SERVICE notificationparameters ...

host_notifications_enabledhost_notification_periodhost_notification_commandshost_notification_options

... addresses ...

... etc ...

Object type: contact

define contact {

}

contact_name Benvealias Christian Benvenuti

... HOST notificationparameters ...

... SERVICE notificationparameters ...

service_notifications_enabledservice_notification_periodservice_notification_commandsservice_notification_options

... addresses ...

... etc ...

Object type: contactdefine contact { contact_name benve alias Christian Benvenuti email benve@univabc.edu.ni

host_notifications_enabled 1 host_notification_period 24x7 host_notification_commands host-notify-by-email host_notification_options d,u,r

service_notifications_enabled 1 service_notification_period 24x7 service_notification_commands notify-by-email service_notification_options w,c,u,r}

Object type: contactgroup

define contact { contact_name admin1 alias Christian Benvenuti email benve@univabc.edu.ni ...}define contact { contact_name admin2 alias Elvis Presley email elvis@univabc.edu.ni ...}define contactgroup { contactgroup_name net_admins alias Administradores de red members admin1, admin2} Another option: contactgroup_members

define hostescalation {

}

define serviceescalation {

}

Escalations (object types)

host_namehostgroup_name

first_notificationlast_notificationnotification_interval

contactscontactgroups

escalation_periodescalation_options

host_namehostgroup_nameservice_description

contactscontactgroups

first_notification last_notificationnotification_interval

escalation_periodescalation_options

Example 1 (1/2)

Internet

net-admin

WWW

www-admin mail-admin

...

10.0.1.100

define serviceescalation {

}

Example 1 (2/2)

host_name WWWservice_description WWW

first_notification 2last_notification 0notification_interval 60

contacts net-admincontactgroups

escalation_period daytimeescalation_options u,d,r

define contact {contact_name www-adminalias Cippa Lippaemail cippa@abc.edu.niservice_notifications_enabled 1service_notification_period 24x7service_notification_commands notify-by-emailservice_notification_options d,u,r...

}define contact {

contact_name net-adminalias Pinco Pallaemail pinco@abc.edu.niservice_notifications_enabled 1service_notification_period 24x7service_notification_commands notify-by-emailservice_notification_options d,u,r...

}

define timeperiod {timeperiod_name daytimealias 8am - 6pmmonday 08:00-18:00tuesday 08:00-18:00wednesday 08:00-18:00thursday 08:00-18:00friday 08:00-18:00saturday 08:00-12:00

}

define host {host_name WWWalias Web Serveraddress 10.0.1.100 ...

}define service {

host_name WWWservice_description WWWcontacts www-admin...

}

Example 2 (1/2)

router1

router2

router3

grp_routers

ENG net

HR net

Internet

ServiceProvider

net-admin-eng

net-admin-hr

grp_it_escalation

define hostescalation {

}

Example 2 (2/2)

host_namehostgroup_name grp_routers

first_notification 4last_notification 0notification_interval 60

contactscontactgroups grp_it_escalation

escalation_periodescalation_options u,d,r

define contact {contact_name net-admin-engalias Christian Benvenutiemail admin@abc.eng.edu.nihost_notifications_enabled 1host_notification_period 24x7host_notification_commands host-notify-by-emailhost_notification_options d,u,r...

}define contact {

contact_name net-admin-hralias Pinco Pallaemail admin@abc.hr.edu.nihost_notifications_enabled 1host_notification_period 24x7host_notification_commands host-notify-by-emailhost_notification_options d,u,r...

}define contactgroup { contactgroup_name grp_it_escalation alias Escalation group members net-admin-eng, net-admin-hr }

define hostgroup { hostgroup_name grp_routers alias All routers members router1, router2, router3}

Parents and Dependencies

● Parents● Host – Host

● Dependencies● Host/s - Host/s● Service/s – Service/s

Is the difference between the following two cases clear?

● Parent (host-host)● Dependencies (host-host)

Parents / Host-HostExample 1

NagiosInternet

WWW(10.0.2.100)

10.0.2.1

10.0.1.110.0.1.2

Mail(10.0.2.101)

Router

define host { host_name WWW alias Web Server address 10.0.2.100 parents Router ...}

define host { host_name Mail alias Mail Server address 10.0.2.101 parents Router ...}

define host { host_name Router alias Main router address 10.0.1.1 ...}

Parents / Host-HostExample 2

Nagios

Internet

WWW(10.0.2.100)

10.0.2.1

10.0.1.1

10.0.1.2

Mail(10.0.2.101)

Router

define host { host_name WWW alias Web Server address 10.0.2.100 parents Router ...}

define host { host_name Mail alias Mail Server address 10.0.2.101 parents Router ...}

define host { host_name Router alias Main router address 10.0.1.1 ...}

?

Parents / Host-HostExample 3

Nagios

Internet

WWW(10.0.2.100)

10.0.2.1

10.0.1.1

Mail(10.0.2.101)

Routerdefine host { host_name WWW alias Web Server address 10.0.2.100 parents Router ...}

define host { host_name Mail alias Mail Server address 10.0.2.101 parents Router ...}

define host { host_name Router alias Main router address 10.0.1.1 ...}

?

Parents / Host-HostExample 4

Nagios

Internet

WWW(10.0.3.100)

10.0.3.1

10.0.2.2

10.0.1.2

Mail(10.0.3.101)

Router1define host { host_name WWW alias Web Server address 10.0.2.100 parents ??? ...}

define host { host_name Mail alias Mail Server address 10.0.2.101 parents ??? ...}

define host { host_name Router alias Main router address 10.0.1.1 ...}

Router2

10.0.2.1

10.0.1.1

Dependencies / Host-Host

● It is not the same as parent-child● This relationship does not depend on the network

topology

Dependencies / Service-ServiceExample 1

NagiosInternet

Mail(10.0.2.100)

10.0.2.1

10.0.1.110.0.1.2

DNS(10.0.2.101)

Router

define host {host_name Mailalias Mail server (SMTP/IMAP)Address 10.0.2.100check_command check-host-alive...

}define service {

host_name Mailservice_description SMTP servercheck_command check_smtp...

}define service {

host_name Mailservice_description IMAP servercheck_command check_imap...

}define host {

host_name DNSalias Primary DNS Serveraddress 10.0.2.101check_command check-host-alive...

}define service {

host_name DNSservice_description Primary DNS servercheck_command check_dns...

}

define servicedependency {host_name DNSservice_description DNS Serverdependent_host_name Maildependent_service_description Mail Server (SMTP/IMAP)execution_failure_criteria c,unotification_failure_criteria c,u

}

Critical, Unknown

Dependencies / Service-ServiceExample 2

Nagios

Internet

Mail(10.0.2.100)

10.0.2.1

10.0.1.1

10.0.2.2

DNS(10.0.2.101)

Router

define host {host_name Mailalias Mail server (SMTP/IMAP)Address 10.0.2.100check_command check-host-alive...

}define service {

host_name Mailservice_description SMTP servercheck_command check_smtp...

}define service {

host_name Mailservice_description IMAP servercheck_command check_imap...

}define host {

host_name DNSalias Primary DNS Serveraddress 10.0.2.101check_command check-host-alive...

}define service {

host_name DNSservice_description Primary DNS servercheck_command check_dns...

}

define servicedependency {host_name DNSservice_description DNS Serverdependent_host_name Maildependent_service_description Mail Server (SMTP/IMAP)execution_failure_criteria c,unotification_failure_criteria c,u

}

?

Dependencies / Service-ServiceExample 3

Nagios

Internet

Mail(10.0.2.100)

10.0.2.1

10.0.1.1

DNS(10.0.2.101)

Router

define host {host_name Mailalias Mail server (SMTP/IMAP)Address 10.0.2.100check_command check-host-alive...

}define service {

host_name Mailservice_description SMTP servercheck_command check_smtp...

}define service {

host_name Mailservice_description IMAP servercheck_command check_imap...

}define host {

host_name DNSalias Primary DNS Serveraddress 10.0.2.101check_command check-host-alive...

}define service {

host_name DNSservice_description Primary DNS servercheck_command check_dns...

}

define servicedependency {host_name DNSservice_description DNS Serverdependent_host_name Maildependent_service_description Mail Server (SMTP/IMAP)execution_failure_criteria c,unotification_failure_criteria c,u

}

?

Dependencies / Service-ServiceExample 4

Nagios

Internet

Mail(10.0.2.100)

10.0.2.1

10.0.1.1

DNS(10.0.2.101)

Router

define host {host_name Mailalias Mail server (SMTP/IMAP)Address 10.0.2.100check_command check-host-alive...

}define service {

host_name Mailservice_description SMTP servercheck_command check_smtp...

}define service {

host_name Mailservice_description IMAP servercheck_command check_imap...

}define host {

host_name DNSalias Primary DNS Serveraddress 10.0.2.101check_command check-host-alive...

}define service {

host_name DNSservice_description Primary DNS servercheck_command check_dns...

}

define servicedependency {host_name DNSservice_description DNS Serverdependent_host_name Maildependent_service_description Mail Server (SMTP/IMAP)execution_failure_criteria c,unotification_failure_criteria c,u

}

?

VPN

Dependencies / Service-Service

What are other examples of dependencies between services?

define hostdependency {

}

define servicedependency {

}

DependenciesHost-Host vs Service-Service

dependent_host_namedependent_hostgroup_name

inherits_parent execution_failure_criteria notification_failure_criteriadependency_period

host_namehostgroup_name

dependent_host_namedependent_hostgroup_namedependent_service_description

inherits_parent execution_failure_criteria notification_failure_criteriadependency_period

host_namehostgroup_nameservice_description

define hostdependency {

}

Dependencies

dependent_host_name = X

inherits_parent execution_failure_criteria notification_failure_criteriadependency_period

host_name = Y

X depends on Y

OR

Y depends on X

???

Check thedocumentation

Templates

● They allow you to write configurations easier to maintain and sanity-check

● Inheritance support● Multiple templates support

Templates(= Object Oriented Configuration)

X = 10Y = 120Z = YesK = 0.1A = 1B = 2

X = 10Y = 120Z = YesK = 0.1A = 3B = 12

X = 10Y = 120Z = YesK = 0.1A = 5B = 7

X = 50Y = 0Z = YesK = 0.1A = 5B = 7

Template T1X = 10Y = 120Z = YesK = 0.1

Use Template T1A = 1B = 2

Use Template T1A = 3B = 12

Use Template T1A = 5B = 7

X = 50Y = 0Z = YesK = 0.1A = 5B = 7

Templates(= Object Oriented Configuration)

X = 10Y = 120Z = YesK = 0.1A = 1B = 2

X = 10Y = 120Z = YesK = 0.1A = 3B = 12

X = 10Y = 120Z = YesK = 0.1A = 5B = 7

X = 50Y = 0Z = YesK = 0.1A = 5B = 7

Template T1X = 10Y = 120

Use Templates T1,T2A = 1B = 2

Use Templates T1,T2A = 3B = 12

Use Templates T1,T2A = 5B = 7

Use Template T2X = 50Y = 0A = 5B = 7

Template T2Z = YesK = 0.1

Templates(= Object Oriented Configuration)

X = 10Y = 120Z = YesK = 0.1A = 1B = 2

X = 10Y = 120Z = YesK = 0.1A = 3B = 12

X = 10Y = 120Z = YesK = 0.1A = 5B = 7

X = 10Y = 120Z = NoK = 0.5A = 5B = 7

Template T1X = 10Y = 120

Use Template T2A = 1B = 2

Use Template T2A = 3B = 12

Use Template T2A = 5B = 7

Use Template T1Z = 10K = 0.5A = 5B = 7

Template T2Use Template T1Z = YesK = 0.1

What if I addX = 11here?

Templates● Special keywords

● register– The parameter passed to the option register is what

distinguishes objects (value 1) from templates (value 0)● use

– Used to list the template/s to use

define host { name WWW1 A = 1 B = 2 C = 5 register 1}

define host { name WWW2 A = 1 B = 2 C = 6}

define host { name WWW-generic A = 1 B = 2 register 0}

define host { use WWW-generic name WWW3 C = 7}

Event Handlers

● Exercise:● Using the online documentation try to understand

what this feature is used for and how to configure it

Active checks vs Passive checks

● Exercise:● Using the online documentation try to understand

what the difference between the two types of checks are (no need to understand the configuration for now, just the functionality)

Active checks vs Passive checks

● Active checks● You configure Nagios to periodically check the status of

hosts/services

● Passive checks● You configure Nagios to accept asynchronous

hosts/services check status information from other applications– Special case: info received from another (or more than one)

Nagios instance

● Active and passive checks are not exclusive● Active checks can be configures to kick-in if no passive

check info is received for a given amount of time

Passive checks

● They make sense mainly when:● the check process/scheme requires a variable and

possibly long time to execute, or● another application already implements the logic

required to determine the status of a host/service and can be configured to return it asynchronously.

Passive checks

...accept_passive_service_checks = 1accept_passive_host_checks = 1

...

FC12: /etc/nagios/nagios.cfg

define host {host_name router_engalias Router Engineering campus...active_checks_enabled 1passive_checks_enabled 1

}

0 00 11 01 1

define service {host_name web_server , ...service_description WEB server...active_checks_enabled 0passive_check_enabled 1

}

All combinationsare valid

Exercise:Check the documentation and find outwhat “Freshness” is with regards topassive checks.

● Exercise● Find the location of the file nagios.cmd and

determine what it is and what it is used for.

# ls /var/spool/nagios/cmd/nagios.cmd -laprw-rw----. 1 nagios nagios 0 2010-02-12 17:20 /var/spool/nagios/cmd/nagios.cmd

# locate nagios.cmdOR# rpm -ql nagios | grep cmdOR...

# file /var/spool/nagios/cmd/nagios.cmd/var/spool/nagios/cmd/nagios.cmd: fifo (named pipe)

(The examples above assume you are using the default installation with FC12)

Nagios Command PIPE

Nagios

process

Filesystem

/

spool

nagios

cmd

nagios.cmd

ApplicationXYZ

NOTE:The PIPE is unidirectional.Is it clear what this means?

Nagios Service Check Acceptor (NSCA)

Nagiosprocess

Filesystem

/

spool

nagios

cmd

nagios.cmd

ncsaserver

ncsaclient

(send_nsca)

ApplicationXYZ

(it could beanother Nagios)

Nagios Service Check Acceptor (NSCA)

ncsaclient

(send_nsca)

(The example assumes you are using the default installation with FC12)

server_port = 5667nsca_user = nagios

command_file = password = decryption_method =

password =encryption_method =

/etc/nagios/nsca.cfg /etc/nagios/send_nsca.cfg

What about theserver port number?

5667

ncsaserver(nsca)

NSCA – Running Options

● OPTIONAL Exercise● By default FC12 installs NSCA as a standalone

service, but you can configure it so that it runs via inetd/xinetd.

● What are the differences between the two alternatives (ie, standalone vs xinetd)?

Web Interface

Web InterfaceWhat could be the problem here?

Web Interface

● Starting/Stopping Nagios● Default account● Adding new users

● Managing passwords● Managing permissions

● Executing commands● How to read the information

How many of youknow how to

configure a web serverlike Apache?

Starting/stopping the server

Configuring permissions

Configuring users/passwords

Log files

Directory aliases

Apache – quick review

● Starting/Stopping the server● service httpd start|stop|status

How many of youknow how to

configure a web serverlike Apache?

Starting/stopping the server

Configuring permissions

Configuring users/passwords

Log files

Directory aliases

Internal Network(10.0.0.0/16)

Apache – quick review● Configuring permissions

● Example “Allow only internal hosts to access it”

Order Deny, Allow

Deny From All

Allow From 10.0.0.0/16

How many of youknow how to

configure a web serverlike Apache?

Starting/stopping the server

Configuring permissions

Configuring users/passwords

Log files

Directory aliases

Nagios(+Apache)

Internet

Where do Iconfigure this?

Apache – quick review● Configuring user/password: htpasswd

● Example that adds the user guest– htpasswd /etc/nagios/passwd guest

How many of youknow how to

configure a web serverlike Apache?

Starting/stopping the server

Configuring permissions

Configuring users/passwords

Log files

Directory aliases

What package doesthis command belongto?

How do I determine whichpasswd file to use?

Does this “user” have toexist in /etc/passwd too?

Apache – quick review● Directory aliases alias /nagios/ /usr/share/nagios/html/ scriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/

How many of youknow how to

configure a web serverlike Apache?

Starting/stopping the server

Configuring permissions

Configuring users/passwords

Log files

Directory aliases

This is configured automatically when youinstall Apache and Nagios via tools like yum (on Fedora).However, when you install Nagios from source code, you must know how to configure the above aliases explicitly.Do you know how to do it?

Apache – quick review● Log files

● /var/log/httpd/...

How many of youknow how to

configure a web serverlike Apache?

Starting/stopping the server

Configuring permissions

Configuring users/passwords

Log files

Directory aliases

Exercise

Nagios Apache

Filesystem

/

Web Interface

● Starting/Stopping Nagios● How do you do (and test) it in Fedora?

● Default account● Adding new users

● Managing passwords● Managing permissions

● Executing commands● How to read the information

Web Interface

● Starting/Stopping Nagios● Default account

● nagiosadmin● What can you do if you can't find/remember the

password?

● Adding new users● Managing passwords● Managing permissions

● Executing commands● How to read the information

Web Interface

● Starting/Stopping Nagios● Default account● Adding new users

● Managing passwords– You configure passwords with the ....................... command.

● Managing permissions

● Executing commands● How to read the information

Web Interface

● Starting/Stopping Nagios● Default account● Adding new users

● Managing passwords● Managing permissions

– Who can access what: Apache config + Nagios config– (NAGIOS: ...)

● Executing commands● How to read the information

Web Interface

● Starting/Stopping Nagios● Default account● Adding new users

● Managing passwords● Managing permissions

● Executing commands● For each contact/user you can specify what objects (hosts/services)

he/she can check.

● With a combination of the object and contact configurations you can specify what commands the contacts can execute on the objects.

● How to read the information

Web Interface

● Starting/Stopping Nagios● Default account● Adding new users

● Managing passwords● Managing permissions

● Executing commands● How to read the information

● The interface is pretty intuitive. Let's play a bit with it ...

This class is based on the

Fedora Core 12 distribution.

Before we start with the labs ...

● You know how to install an application (rpm, yum, ...)

● You know how to determine what configuration files an application uses

● You know how to start and stop a system service● service <service_name> status|start|stop

● You know where to find and how to use log files (syslog, /var/log/....)

● You know how to check the firewall configuration and clear it if necessary.

Right?

Installation and basic configuration (1/2)

● FEDORA: yum install nagios● (in FC12 servono pure tutte le plugins una a una,

vedi p.87 del libro)

● Optional exercise: install it from the tarball● Linux packet management is outside the scope of

this workshop and you are assumed to be able to install applications from the source code. I therefore suggest you trying to install (the very latest version of) Nagios from the tarball.

Installation and basic configuration (2/2/)

● Managing the system service nagios● service nagios <COMMAND>

● What is the main configuration file/directory?● Let's look at the Nagios config file/s together ...

● Organization of the config files for a complex setup

Exercises

.6.5.4

.3 .2 .1

Net 10.0.1.0/24

Net 10.0.3.0/24 Net 10.0.4.0/24

Net 10.0.2.0/24

.1 .2 .3

.4.5.6

.1 .2 .3.1

.6

.3

Net 10.0.5.0/24

.1 .2

.3.4

Internet

eth0

eth1eth1

eth1eth1

eth0

eth0eth0

.5

.2

.5.4 .4.5.6

.6.5.4

.3 .2 .1

Net 10.0.X.0/24

Exercise 1

In each group:●Let's install and configure NAGIOS on the router.●Let's define a host instance for each host in the group.●Let's define a host group that includes all the hosts of the group.

Exercise 2

.6.5.4

.3 .2 .1

Net 10.0.1.0/24

Net 10.0.5.0/24

.1

eth0

eth1

.5

In each group:

● Let's define a host instance for the main router 10.0.5.5 and one for the DNS server/s

● For the DNS server/s let's also define a DNS service.

● Let's define a host group where to include the main router and the DNS server/s.

Any problemhere?

Exercise 3

.6.5.4

.3 .2 .1

Net 10.0.1.0/24

Net 10.0.3.0/24 Net 10.0.4.0/24

Net 10.0.2.0/24

.1

.1.1

Net 10.0.5.0/24

.1 .2

.4.3

eth0

eth1 eth1

eth1eth1

In each group:●Let's define a host instance for each router●Let's define a host group that includes all the routers

.5

Exercise 4

.2 .1

Net 10.0.1.0/24

Net 10.0.3.0/24 Net 10.0.4.0/24

Net 10.0.2.0/24

.1 .2

.1 .2.1

Net 10.0.5.0/24

.1 .2

.3.4

eth0

eth1eth1

eth1eth1

eth0

eth0eth0

.5

.2WEB

WEB WEB

WEB

In each group:●Let's configure the host with address 10.0.x.2 as the group web server●Let's create an host instance for the web server of each group●Let's define a host group that includes all web servers●Let's define the web servers as depending on the associated routers

More exercises here ... if we have time.

Documentacion● http://www.nagios.org●

● + many articles/tutorials freely available

Copyright● This presentation is released under the

Creative Common License:● Attribution, Noncommercial, Share Alike 2.5● (http://creativecommons.org/licenses/by-nc-sa/2.5/)

● Attribution

● You must attribute the work in the manner specified by the author or licensor.

● Noncommercial.

● You may not use this work for commercial purposes.

● Share Alike.

● If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.

CCCreativeCommons