nagios-quick_reference_guide-enus.pdf
TRANSCRIPT
-
8/13/2019 Nagios-Quick_Reference_Guide-ENUS.pdf
1/2
NagiosQuick Reference
Guide
http://pessoa.eti.br/
2nd edition - november 2010
Content
Nagios daemon
Notifications Hosts
Services
Extended Information
Status Map
Contacts
Plugins
Time periods
Macros
Commands Groups
define timeperiod{
timeperiod_name workhours
alias Standard Work Hours monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}
Objective:
Nagios administrators can define time periods and use them to on
command and service check definition, notification periods and
contact notification periods.
The time periods more used are 24x7and workhours.
Time period
$HOSTNAME$: Short name for the host.
$HOSTADDRESS$: Address of the host.
$NOTIFICATIONTYPE$ : A string identifying the type of notification
that is being sent (PROBLEM, RECOVERY, ACKNOWLEDGEMENT,
FLAPPINGSTART, FLAPPINGSTOP,
FLAPPINGDISABLED, DOWNTIMESTART,
DOWNTIMEEND, or DOWNTIMECANCELLED).
$HOSTSTATE$: A string indicating the current state of the host
(UP, DOWN, or UNREACHABLE).
$HOSTOUTPUT$: The first line of text output from the last host check
(i.e. "Ping OK").
$LONGDATETIME$: Current date/time stamp
(ex.: Fri Feb 13 23:31:30 UTC 2009).
$CONTACTEMAIL$: Email address of the contact being notified.
Macros(partial)
define command{
command_name check_https
command_line /usr/local/nagios/plugins/check_http
--ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$
}
Descrio:
command_name: A short name to identify the command.
command_line: Used to define what is executed by Nagios. All
macros are replaced before command execution.
Command
define contact{
contact_name user
alias Nagios user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email root@localhost
}
Objective:
Define a contact to receive notifications.
Description:
contact_name: A short name to identify de contact, like login name.
alias: A longer name or description for the contact.
service_notification_period : The short name of the time
period during which the contact can be notified about service alerts.
host_notification_period: The short name of the time period
during which the contact can be notified about host alerts.
service_notification_options : Define the service states for
which notification scan be sent. Valid options* are: w, u, c, r, f, n.
host_notification_options: Define the host states for which
notification can be sent out. Valid options* are:d,u,r,f,s,n.
service_notification_commands : Define a list of the shot names
of the commands used to notify a service alert.
host_notification_commands : Define a list of the shot names of
the commands used to notify a host alert. Multiple commands
should by separated by commas.
email: Define an email address for the contact. **
* See Notification(on cover) learn more about options.
** A mail delivery system (MTA) must be configured on Nagios server.
Contacts
Mrcio Pessoa
http://pessoa.eti.br/
Written in BrazilVersion: 2010-11-16_21-14-53
Nagios daemon
Nagios start
/etc/init.d/nagios start
Nagios stop
/etc/init.d/nagios stop
Nagios restart
/etc/init.d/nagios restart
Reload Nagios configuration files
/etc/init.d/nagios reload
After modify the configuration files, run sanity check,
before (re)start Nagios, otherwise Nagios can break downand stop monitoring processes:
nagios -v /etc/nagios/nagios.cfg
-
8/13/2019 Nagios-Quick_Reference_Guide-ENUS.pdf
2/2
Use the options bellow both hosts and services:
max_check_attempts 4
notification_interval 240
notification_period 24x7
contact_groups admins
check_period 24x7
Use the options bellow in host definitions:
notification_options d,u,r,f,s
Use the options bellow in service definitions:
notification_options w,u,c,r,f,s
Description:
max_check_attempts: The number of times that is defined to retry
check command before generate an alert.
notification_interval: The time to wait before re-notifying.
notification_period: The short name of the time period during
which notifications of events can be sent.
contact_groups: A list of the short names of the contact groups
that should be notified whenever there are alerts.
check_period: The time period used in active checks.
notification_options: Notifications should be sent out when:
d: Host down.
u: Host unreachable, or Service unknown state.
r: recovery (OK State).
w: Service warning.
c: Service critical.
f: Flapping (start and stop).
s: Scheduled downtime (start and end).
n: No notification will be sent out.
Notification
define host{
host_name gateway
alias Default Gateway
address 192.168.1.1
use generic-host
}
Description:
host_name: A short name to identify the host.
alias: A description to identify the host.
address: Endereo IP ou nome DNS.
use: Template.
Hosts
define service{
host_name gateway
service_description PING
check_command check_ping!100,20%!500,60%
use generic-service
}
Description:
host_name: A short name to identify the host. The hostgroup_name
directive may be used instead of, or in addition to, the host_name
directive.
service_description: A description of the service.
check_command: The short name of the command used to check
status of the service.
Service
define hostextinfo{
host_name gateway
icon_image black_box.png
icon_image_alt Linux router - Yeah!
statusmap_image black_box.gd2
notes_url http://example.com/
}
define serviceextinfo{
host_name gateway
service_description Network traffic
icon_image traffic.png
icon_image_alt Traffic packet data
notes Traffic on interface eth1
notes_url http://example.com
}
Description:
host_name: A short name to identify the host.
service_description: A description of the service.
icon_image: Define the name of a image file (gif, png or jpg format).
icon_image_alt: An optional string that is showed when the mouse is
over the icon image on web interface.
statusmap_image: A image file used on status map (GD2 format).
notes: An optional string of notes pertaining to the object.
notes_url: An optional URL that can be used to provide more
information about the object.
Tip:
After Nagios 3.x, all extended information can be used directly on
host/service definitions. Conventional extended information format
will continue to be supported for backward compatibility.
Extended Information
Use the parents option in a host definition to organize theStatus Map. This option also enable Nagios to recognize
unreacheable hosts when a parent host is down.
Example:
define host{
host_name mail-server
alias Foo Mail Server
address mail-server.example.com
use generic-host
parents gateway }
Status Map
define hostgroup{
hostgroup_name Webservers
alias Web servers on internet
members web-server, mail-server
}
Description:
hostgroup_name: A short name used to identify the host group.
alias: A description to identify the host group.
members: A list of the short names of the hosts. Multiple host names
should be separated by commas.
The hostgroup_membersdirective may be used instead of, the
members directive. So a group of host groups can be created.
Host group
define servicegroup{
servicegroup_name Mail
alias Mail related services
members NS1,DNS, mail-server,SMTP, mail-
server, POP3, mail-server,IMAP }
Description:
servicegrop_name: A short name used to identify the service
group.
alias: A description to identify the service group.
members: A list of the descriptions of services and the name of their
corresponding hosts that should be included in this group. Host and
service should be separated by commas. The format is $HOSTNAME
$, $SERVICEDESC$, $HOSTNAME$, $SERVICEDESC$, etc...
The servicegroup_members directive may be used instead
of, the members directive. So a group of service groups can
be created.
Service group
Legal:
Nagios and Nagios Logo are owned by
Nagios Enterprises.