Anda di halaman 1dari 3

Nagios Configuration Example

1. Definition of Host: Nagios will monitor each host using by default ICMP protocol and send
alerts when the host is down, up, unreachable or flapping (each notification can be set to
our needs)

Host Template

define host{
host_name App_Switch ; Host name
alias App_Switch N#1 ; Alias or description for host
address 192.168.1.254 ; Host IP
parents server-backbone ; If host depends on another host
check_command check-host-alive ; which command will execute to
check host status (by default=ping)
check_interval 5 ; each 5 minutes it will check host
status
retry_interval 1 ; if host goes down, check is per
minute
max_check_attempts 5 ; check attempts when host is
down
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0 ; retain host status if nagios restart
contact_groups switch-admins ; how will receive alerts
first_notification_delay 15 ; time units to wait if host goes
down
notification_interval 30 ; time period in which notifications
can be sent out to contacts.
notification_period 24x7
notification_options d,u,r ; Status down= d Status Up=u
Status unreachable= U Flapping = f
statusmap_image switch.png ; Image displayed in Nagios
icon_image switch.png ; Image dispayed in Nagios Map
}
Other definitions can be used:

https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectdefinitions.html
2. Definitions of Services: For each defined host it´s possible to set as many services we want
to monitor:
Nagios has a predefined list of services:
 CPU usage
 Memory usage
 Interface Status
 SNMP traps
 Ping or ICMP
 Users
 Processes
 Load

There are many plugins that can be added in order to monitor other services, example:

 Multiple pings per host

Service Template

define service{

host_name App_Switch
service_description check-disk-sda1
check_command check-disk!/dev/sda1 ; will check disk
usage
max_check_attempts 5
check_interval 5
retry_interval 3
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options w,c,r
contact_groups switch-admins
}

Check commands examples:

Ping:

define service{
use generic-service ; Inherit values from a template
host_name linksys-srw224p ; The name of the host the service
is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; Will check packet
loss and latency
normal_check_interval 5 ; Check the service every 5 minutes under normal
conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard
state is determined
}
SNMP Status Information

define service{
use generic-service ; Inherit values from a template
host_name linksys-srw224p
service_description Uptime
check_command check_snmp!-C public -o sysUpTime.0 ; need to
set up SNMP community and OID
}

Interface Status

define service{
use generic-service ; Inherit values from a template
host_name linksys-srw224p
service_description Port 1 Link Status ; will monitor Port Status
check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-
MIB
}
Bandwidth

define service{
use generic-service ; Inherit values from a template
host_name linksys-srw224p
service_description Port 1 Bandwidth Usage
check_command
check_local_mrtgtraf!/var/lib/mrtg/192.168.1.253_1.log!AVG!1000000,2000000!5000000,
5000000!10
}