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/bin
2、启动nrpe,端口为5666
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d netstat-ant|grep5666 tcp400*.5666*.*LISTEN
二、监控服务器上的配置
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/libexec
2、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/apachectlrestart
nagios监控网络服务器和网络服务问题的解决就结束了,有关nagios的基础内容您可以
转载请注明:IT运维空间 » 安全防护 » nagios监控网络服务器和网络服务故障解决篇
发表评论