handbook:handbook:nagios:nagios
This is for RHEL 5.2
1. EPEL repositories for nagios:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
2. install nagios and plugins, including nrpe
yum install nagios nagios-plugins nagios-devel nagios-plugins-nrpe nrpe nagios-plugins-disk nagios-plugins-load nagios-plugins-ping nagios-plugins-ssh nagios-plugins-users nagios-plugins-procs nagios-plugins-swap
3. verify nagios config file:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
4. set password
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
5. configure cgi.cfg
# AUTHENTICATION USAGE use_authentication=1 # SYSTEM/PROCESS INFORMATION ACCESS authorized_for_system_information=nagiosadmin # CONFIGURATION INFORMATION ACCESS authorized_for_configuration_information=nagiosadmin # SYSTEM/PROCESS COMMAND ACCESS authorized_for_system_commands=nagiosadmin # GLOBAL HOST/SERVICE VIEW ACCESS authorized_for_all_services=nagiosadmin authorized_for_all_hosts=nagiosadmin # GLOBAL HOST/SERVICE COMMAND ACCESS authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin
6. Edit /etc/httpd/conf.d/nagios.conf
Change allow from 127.0.0.1 to allow from all
7. Edit /etc/nagios/nagios.cfg
Uncomment cfg_dir=/etc/nagios/servers
mkdir /etc/nagios/servers && chgrp nagios /etc/nagios/servers && chmod g+s /etc/nagios/servers
8. Add the following code at the end of /etc/nagios/commands.cfg to support querying NRPE plugin on remote hosts
# 'check_nrpe_load' command definition
define command {
command_name check_nrpe_load
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c "check_load"
}
# 'check_nrpe_mem' command definition
define command {
command_name check_nrpe_mem
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c "check_mem"
}
# 'check_imm_health' command definition
define command {
command_name check_imm_health
command_line $USER1$/check_imm -H $HOSTADDRESS$ -C public -T health
}
9. Verify nagios config
nagios -v /etc/nagios/nagios.cfg
10. Add server configurations to /etc/nagios/servers . server name server1.cfg
define host{
host_name server1
alias Server01
address xxx.xxx.xxx.xxx
use special-host
contact_groups admins
hostgroups whatever
}
define service {
use special-service
check_command check_ping!80.0,80%!160.0,100%
host_name server1
service_description PING
contact_groups admins
}
define service{
use special-service
host_name server1
service_description Current Users
check_command check_nrpe!check_users
contact_groups admins
}
define service{
use special-service
host_name server1
service_description SYSTEM LOAD
check_command check_nrpe!check_load
contact_groups admins
}
define service{
use special-service
host_name server1
service_description SWAP
check_command check_nrpe!check_swap
contact_groups admins
}
Switch config under servers dir.:
define host{
host_name switch1
alias Switch1
address 10.2.3.223
use special-host
contact_groups admins
hostgroups hardware
}
define service {
use special-service
check_command check_ping!80.0,80%!160.0,100%
host_name switch_1
service_description PING
contact_groups admins
}
11.
#cat contactgroups.cfg
# contact group definitions
define contactgroup{
contactgroup_name admins
alias Nagios Admins
members nagios
}
12.
#cat contactgroups.cfg
define contact{
contact_name nagios
alias nagios
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email nagios@localhost
}
13.
# cat hostextinfo.cfg
define hostextinfo {
host_name server1
action_url /nagios/pnp4nagios/index.php?host=$HOSTNAME$
}
define hostextinfo {
host_name server2
action_url /nagios/pnp4nagios/index.php?host=$HOSTNAME$
}
define hostextinfo {
host_name server3
action_url /nagios/pnp4nagios/index.php?host=$HOSTNAME$
}
etc.
14.
#cat hostgroups.cfg
define hostgroup{
hostgroup_name cluster
alias Cluster
}
define hostgroup{
hostgroup_name hardware
alias Hardware
}
15. add at the end of hosts.cfg the following lines:
define host{
use generic-host
host_name server1
alias server1
address x.x.x.x
max_check_attempts 15
notification_interval 0
notification_period none
contact_groups cluster
# notification_options d,r #overrides the basic-host option
}
define host{
use generic-host
host_name server2
alias server2
address x.x.x.x
max_check_attempts 15
notification_interval 0
notification_period none
contact_groups cluster
# notification_options d,r #overrides the basic-host option
}
define host{
use generic-host
host_name server1
alias server1
address x.x.x.x
max_check_attempts 15
notification_interval 0
notification_period none
contact_groups cluster
# notification_options d,r #overrides the basic-host option
}
16. host_templates.cfg
define host {
name normal-host
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
check_command check-host-alive
max_check_attempts 3
notification_interval 60
notification_period 24x7
notification_options d,u,r,f
register 0
#use host-pnp
#action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define host {
name special-host
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
check_command check-host-alive
max_check_attempts 1
notification_interval 30
notification_period 24x7
notification_options d,u,r,f
register 0
#use host-pnp
#action_url /nagios/pnp4nagios/index.php?host=$HOSTNAME$
}
— Eduard Goiu 2011/08/17 09:05
handbook/handbook/nagios/nagios.txt · Last modified: by eduard
