[iyunv@nagios-server etc]# vi/usr/local/nagios/etc/nagios.cfg +34
# You can specify individualobject config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
2)注意:需要注释掉如下localhost.cfg行,否则和我们要配的会冲突原 36 行
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
3)需要在host.cfg 里添加客户端主机和主机组(HOSTGROUP)
[iyunv@nagios-serveretc]# cd /usr/local/nagios/etc/objects/ [iyunv@nagios-server objects]# vihosts.cfg
# Define a host for the local machine
define host{
use linux-server
host_name 18-client01
alias 18-client01
address 192.168.1.18
}
define host{
use linux-server
host_name 19-nagios_server
alias 19-nagios_server
address 192.168.1.19
}
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of thegroup
members 18-client01,19-nagios_server
}
4)同理添加要监控的服务配置到service.cfg
[iyunv@nagios-serverobjects]# cd /usr/local/nagios/etc/objects/
[iyunv@nagios-serverobjects]# vi services.cfg
define service {
use generic-service
host_name 18-client01
service_description Disk Partition
check_command check_nrpe!check_disk
}
问题2:
Checking services...
Error: There are no servicesdefined!
Checked 0 services. 处理方法:
[iyunv@nagios-serverobjects]# vi services.cfg
defineservice {
use generic-service
host_name 18-client01
service_description Disk Partition
check_command check_nrpe!check_disk
}
"services.cfg"8L, 138C written
3)问题3 问题3:
Checking services...
Error: Service check command'check_nrpe' specified in service 'Disk Partition' for host '18-client01' notdefined anywhere!
Checked 1 services. 处理方法:
[iyunv@nagios-serverobjects]# vi commands.cfg
#'check_nrpe' command definition
definecommand{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c$ARG1$
}
4)问题4
打开网页会出现
It appears as though you do not have permission toview information for any of theservices you requested... 解决方法
[iyunv@nagiosserver objects]#cd/usr/local/nagios/etc
[iyunv@nagiosserver objects]#vi cgi.cfg +119
#把在1.6 节建立的用户oldboy 加到后面,注意用逗号隔开。
#default_user_name=oldboy
authorized_for_system_information=nagiosadmin,oldboy
authorized_for_configuration_information=nagiosadmin,oldboy
authorized_for_system_commands=nagiosadmin,oldboy
authorized_for_all_services=nagiosadmin,oldboy
authorized_for_all_hosts=nagiosadmin,oldboy
authorized_for_all_service_commands=nagiosadmin,oldboy
authorized_for_all_host_commands=nagiosadmin,oldboy