首页 男生 其他 跟老男孩学Linux运维:Web集群实战

14.5.3 Nagios的调试

  您可以在百度里搜索“跟老男孩学Linux运维:Web集群实战 艾草文学(www.321553.xyz)”查找最新章节!

  

  14.5.3 Nagios的调试

  1.检查Nagios语法并优化配置Nagios启动脚本

  字符串检查的语法如下:

  /usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg

  优化配置Nagios启动脚本中检查语法的部分。

  [root@nagios-server ~]#vi /etc/init.d/nagios +178 176checkconfig) 177 printf "Running configuration check..." 178#$NagiosBin -v $NagiosCfgFile > /dev/null 2> 179$NagiosBin -v $NagiosCfgFile;

  这里要注释掉第178行的内容,添加第179行的内容,然后保存,其实也就是去掉了第178行的“>/dev/null2>&1”,让错误在屏幕上打印出来。测试如下:

  [root@nagios-server ~]# /etc/init.d/nagios checkconfig Runningconfiguration check...…省略大部分……这里是详细的检查结果… Total Warnings: 0 TotalErrors: 1…… CONFIG ERROR! Check your Nagios configuration.

  2.检查语法及加载配置

  配置完服务后,就是该检查结果的时候了。

  检查语法的命令如下:

  [root@nagios-server objects]#/etc/init.d/nagios checkconfig

  如果语法错误,需要根据错误信息调试好,然后继续执行检查语法。

  使配置文件生效的命令为/etc/init.d/nagios reload,一般不需要用restart。

  [root@nagios-server ~]# /etc/init.d/nagios reload Runningconfiguration check...done. Reloading nagiosconfiguration...done

  3.通过日志排查问题

  在配置监控出问题后,也可以看看Nagios的日志,有可能会发现一些故障所在。

  [root@web01 ~]# tail /usr/local/nagios/var/nagios.log[1337334508] SERVICE ALERT:179-oldboy;blog_url;CRITICAL;HARD;1;Name or service not known[1337335957] Auto-save of retention data completed successfully.[1337336087] SERVICE ALERT: 179-oldboy;Current Load;OK;HARD;1;OK -load average: 1.79, 1.03, 0.39 [1337336087] SERVICE ALERT:179-oldboy;179-check_22;OK;HARD;1;10.0.0.8 22 is ok. [1337336087]HOST ALERT: 179-oldboy;UP;HARD;1;PING OK - Packet loss = 0%, RTA =2.77 ms [1337336207] SERVICE ALERT:179-oldboy;blog_url;CRITICAL;SOFT;1;Name or service not known[1337336267] SERVICE ALERT:179-oldboy;blog_url;CRITICAL;SOFT;2;Name or service not known[1337336327] SERVICE NOTIFICATION:nagiosadmin;179-oldboy;blog_url;CRITICAL;notify-service-by-email;Nameor service not known [1337337846] Caught SIGTERM, shutting down...[1337337846] Successfully shutdown... (PID=1779) [root@web01 ~]#tail /var/log/messages Jun 7 07:44:59 lvs2 nrpe[25333]: Listeningfor connections on port 5666 Jun 7 07:44:59 lvs2 nrpe[25333]:Allowing connections from: 10.0.0.8 Jun 7 08:01:05 lvs2nrpe[25333]: Caught SIGTERM - shutting down... Jun 7 08:01:05 lvs2nrpe[25333]: Cannot remove pidfile '/var/run/nrpe.pid' - check yourprivileges. Jun 7 08:01:05 lvs2 nrpe[25333]: Daemon shutdown Jun 708:01:09 lvs2 nrpe[25438]: Starting up daemon Jun 7 08:01:09 lvs2nrpe[25438]: Listening for connections on port 5666 Jun 7 08:01:09lvs2 nrpe[25438]: Allowing connections from: 10.0.0.8 Jun 708:01:34 lvs2 nrpe[25440]: Error: Could not complete SSL handshake.5 Jun 7 08:19:07 lvs2 nrpe[25558]: Error: Could not complete SSLhandshake. 5

  上述日志中的Error部分就是监控报警的故障。 跟老男孩学Linux运维:Web集群实战

目录
设置
手机
书架
书页
评论