nagios添加主机和服务的可能问题如下:
1:如果配置参数有问题,如果不检查配置就启动nagios,启动可能成功,但显示会异常;
解决方案:调整配置参数
2:Connectionrefused
当这个问题出现时,我开始认为是的ssh没有密码登录没有成功,但事实上,我的服务器没有启动服务,启动服务。但这些都是有端口的服务,没有任何检测到端口的状态?nrpe,ok,我们现在正在安装服务器nrpe:
一、远程主机配置
1、安装nrpe与配置
fetchhttp://ufpr.dl.sourceforge.net/sourceforge/nagios/nrpe-2.5.2.tar.gz tarzxvfnrpe-2.5.2.tar.gz cdnrpe-2.5.2 ./configure--enable-ssl--enable-command-args makeall mkdir-p/usr/local/nagios/etc mkdir/usr/local/nagios/bin mkdir/usr/local/nagios/libexec pwaddgroupnagios pwuseraddnagios-gnagios-d/usr/local/nagios/-s/sbin/nologin chown-Rnagios:nagios/usr/local/nagios cp./sample-config/nrpe.cfg/usr/local/nagios/etc cpsrc/nrpe/usr/local/nagios/bin2、启动nrpe,端口为5666
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d netstat-ant|grep5666 tcp400*.5666*.*LISTEN2.监控服务器上的配置
1、安装nrpe(主要用途check_nrpe模块)
fetchhttp://ufpr.dl.sourceforge.net/sourceforge/nagios/nrpe-2.5.2.tar.gz tarzxvfnrpe-2.5.2.tar.gz cdnrpe-2.5.2 ./configure--enable-ssl--enable-command-args makeall cpsrc/check_nrpe/usr/local/nagios/libexec2、nagios文件的配置
vicheckcommands.cfg
定义check_nrpe命令
#'check_nrep'commanddefinition definecommand{ command_namecheck_nrpe command_line/usr/local/nagios/libexec/check_nrpe-H$HOSTADDRESS$-c$ARG1$ }以上我们已经配置了部分参数
以下是配置的最终结果:
definehost{ usegeneric-host;Nameofhosttemplatetouse host_nametest_nrpe aliasclient address10.5.1.156 check_commandcheck-host-alive max_check_attempts1 check_period24x7 notification_interval120 notification_period24x7 notification_optionsd,r contact_groupsadmins } #'check_load'commanddefinition definecommand{ command_namecheck_load command_line$USER1$/check_load-w$ARG1$-c$ARG2$ } #'check_load'commanddefinition definecommand{ command_namecheck_disk command_line$USER1$/check_disk-w$ARG1$-c$ARG2$ } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptionPING is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_ping!100.0,20%!500.0,60% } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptionapache is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_http!100.0,20%!500.0,60% } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptionmysql is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_mysql!100.0,20%!500.0,60% } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptionntp is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_ntp!100.0,20%!500.0,60% } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptionqmail_smtp is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_smtp!100.0,20%!500.0,60% } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptionqmail_pop3 is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_pop!100.0,20%!500.0,60% } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptiontest_load is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_load!100.0,20%!500.0,60% } defineservice{ usegeneric-service;Nameofservicetemplatetouse host_nametest_nrpe service_descriptiontest_disk is_volatile0 check_period24x7 max_check_attempts1 normal_check_interval1 retry_check_interval1 contact_groupsadmins notification_optionsw,u,c,r notification_interval960 notification_period24x7 check_commandcheck_disk!100.0,20%!500.0,60% }四、检查配置参数并重启nagios
如何在nagios使用外部命令
vi/usr/local/nagios/etc/nagios.cfg check_external_commands=1 mkdir/usr/local/nagios/var/rw chownnagios.nagcmd/usr/local/nagios/var/rw chmodu rw/usr/local/nagios/var/rw chmodg rw/usr/local/nagios/var/rw chmodg s/usr/local/nagios/var/rw svc-t/service/nagios/ /usr/local/apache2/bin/apachectlrestartnagios监控网络服务器和网络服务问题的解决就结束了。nagios您可以参考概念、安装和配置的基本内容