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/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
添加cfg_file=/usr/local/nagios/etc/objects/hosts.cfg和cfg_file=/usr/local/nagios/etc/objects/services.cfg
注释该行cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
[root@centos6 Nagios-Server]# cat /usr/local/nagios/etc/objects/hosts.cfg
define host{
use linux-server
host_name 22-Nagios-Server
alias 22-Nagios
address 192.168.0.22
}
define hostgroup{
hostgroup_name linux-servers
alias Linux Servers
members 22-Nagios-Server
}
[root@centos6 Nagios-Server]# cat /usr/local/nagios/etc/objects/services.cfg
define service{
use generic-service
host_name 22-Nagios-Server
service_description HTTP
check_command check_http
notifications_enabled 0
}
define service{
use generic-service
host_name 22-Nagios-Server
service_description bolg_port_80
check_command check_tcp!80
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 22-Nagios-Server
service_description bolg_port_3306
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
}
define service{
use generic-service
host_name 22-Nagios-Server
service_description Passwd
check_command check_passwd
notifications_enabled 0
}
[root@centos6 Nagios-Server]# cat /usr/local/nagios/etc/objects/ commands.cfg
#‘check_passwd ‘command definintion
define command{
command_name check_passwd
command_line $USER1$/check_passwd -H $HOSTADDRESS$ -c $ARG1$
}
[root@centos6 Nagios-Server]#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[root@centos6 Nagios-Server]#/etc/init.d/nagios reload
具体操作是这样先添加主机、再添加服务、然后添加命令;检查配置最后重载Nagios服务。
备注:可能会出现的故障(有些是关于NRPE错误)
1,登录web界面的时候提示错误:
解决:vim /usr/local/nagios/etc/cgi.cfg 把所有关于nagiosadmin改成你自己添加的用户名,重启服务即可。
2,command ‘check_Passwd‘ not define
解决:到 /usr/local/nagios/etc/objects/ commands.cfg 把它定义好就可以了。
3,Connction refurse host
解决:先cd /usr/local/nagios/libexec 下,使用 ./check_nrpe -H 192.168.0.150 -c check_ping 或者./check_nrpe -H 127.0.0.1 -c check_ping
如果还是提示Connction refurse host;接下来查看NRPE有没有启动:netstat -lntup |grep nrpe 如果没有启动执行
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 然后再执行./check_nrpe -H 192.168.0.150 -c check_ping
4,NRPE command ‘check_disk‘ not define
解决:先ps -ef |grep nrpe
pkill nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
ps -ef |grep nrpe
然后再获取./check_nrpe -H 192.168.0.150 -c check_disk
5,CHECK_NRPE: Error - Could not complete SSL handshake.
解决:vi /usr/local/nagios/etc/nrpe.cfg +79
allowed_hosts=127.0.0.1,192.168.0.22
ps -ef |grep nrpe
pkill nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
ps -ef |grep nrpe
6,NRPE: Unable to read output
解决:./check_nrpe -H 192.168.0.150 -c check_emm 如果还提示NRPE: Unable to read output然后
直接到里面/usr/local/nagios/libexec/check_memory.pl -w 6% -c 3% 如果提示Permission denied
说明 /usr/local/nagios/libexec/check_memory.pl -w 6% -c 3% 没有执行的权限
chmod +x /usr/local/nagios/libexec/check_memory.pl -w 6% -c 3%
原文地址:http://blog.51cto.com/hwg1227/2074594