vi /usr/local/nagios/etc/nagios.cfg +34
#←增加如下两行主机和服务的配置文件
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
并注释掉如下一行
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cd /usr/local/nagios/etc/objects/
vi hosts.cfg
define host {
use linux-server
host_name Nagios-client
alias client
address 192.168.1.191
check_command check-host-alive
max_check_attempts 3
normal_check_interval 2
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options d,u,r
contact_groups admins
process_perf_data 1
}
#######################################################
# HOST GROUP DEFINITION
#create by wancc (qq:942390490)
#######################################################
# Define an optional hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members Nagios-client ;
}
####vi services.cfg
define service {
use generic-service
host_name Nagios-client
service_description Current Load
check_command check_nrpe!check_load
max_check_attempts 2
normal_check_interval 4
retry_check_interval 4
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
process_perf_data 1
}
define service {
use generic-service
host_name Nagios-client
service_description MEM Useage
check_command check_nrpe!check_mem
max_check_attempts 2
normal_check_interval 4
retry_check_interval 4
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
process_perf_data 1
}
define service {
use generic-service
host_name Nagios-client
service_description Swap Useage
check_command check_nrpe!check_swap
max_check_attempts 10
normal_check_interval 3
retry_check_interval 4
check_period 24x7
notification_interval 10
notification_period workhours
notification_options w,u,c,r
contact_groups admins
process_perf_data 1
}
define service {
use generic-service
host_name Nagios-client
service_description Disk Partition
check_command check_nrpe!check_disk
max_check_attempts 8
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
process_perf_data 1
}
define service {
use generic-service
host_name Nagios-client
service_description Disk Iostat
check_command check_nrpe!check_iostat!5!11
max_check_attempts 2
normal_check_interval 4
retry_check_interval 4
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
}
########check url
#check_weburl (http://www.baidu.com) Nagios-client
define service{
use generic-service
host_name Nagios-client
service_description baidu_url
check_command check_weburl!-H www.baidu.com
max_check_attempts 3
normal_check_interval 2
retry_check_interval 1
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
}
define service{
use generic-service
host_name Nagios-client
service_description ssh_52113
check_command check_tcp!52113
max_check_attempts 3
normal_check_interval 2
retry_check_interval 1
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
}
define service{
use generic-service
host_name Nagios-client
service_description http_80
check_command check_tcp!80
max_check_attempts 3
normal_check_interval 2
retry_check_interval 1
check_period atch 24x7
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
}
define service{
use generic-service
host_name Nagios-client
service_description MySQL
check_command check_tcp!3306
max_check_attempts 3
normal_check_interval 2
retry_check_interval 1
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
}
vi commands.cfg ###shift+G到结尾
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#'check_weburl' command definition
definecommand{
command_name check_weburl
command_line $USER1$/check_http $ARG1$ -w 10 -c 30
}
cd /usr/local/nagios/etc/
vi cgi.cfg +119
authorized_for_system_information=nagiosadmin,wancc
authorized_for_configuration_information=nagiosadmin,wancc
authorized_for_system_commands=nagiosadmin,wancc
authorized_for_all_services=nagiosadmin,wancc
authorized_for_all_hosts=nagiosadmin,wancc
authorized_for_all_service_commands=nagiosadmin,wancc
authorized_for_all_host_commands=nagiosadmin,wancc
/etc/init.d/nagios restart
|