千辛万苦,终于把这些配置给做好保存,现在几乎有点迫不及待了,运行程序/usr/local/nagios –v /usr/local/nagios/etc/nagios.cfg来检查所有配置文件的正确性。如果十分幸运的话,运行完毕将在输出尾部出现

  1. Total Warnings: 0  
  2.  
  3. Total Errors: 0  
  4.  
  5. Things look okay - No serious problems were detected during the pre-flight check  
  6.  

这样的情况,大功告成;但我却没有这么幸运,修改了好多个地方才成功。不过值得庆幸的是,这个校验的错误报告时非常有用的(不象有的系统的帮助文档中看不中用)。看我故意设置的一个错误产生的输出:

  1. [root@netmonitor nagios]# bin/nagios -v etc/nagios.cfg  
  2.  
  3. Nagios 2.5  
  4.  
  5. Copyright (c) 1999-2006 Ethan Galstad ([url]http://www.nagios.org[/url])  
  6.  
  7. Last Modified: 07-13-2006  
  8.  
  9. License: GPL  
  10.  
  11. Reading configuration data...  
  12.  
  13. Error: Could not find any host matching 'nagios-server' 
  14.  
  15. Error: Could not expand member hosts specified in hostgroup (config file '/usr/local/nagios/etc/hostgroups.cfg', starting on line 2)  
  16.  

它告诉我配置文件在什么位置产生错误(实际上我故意在配置文件里加了一个注释符号来测试)。验证通过以后,就可以执行命令/usr/local/nagios –d /usr/local/nagios/etc/nagios.cfg 把nagios作为守护进程。然后用ps –aux | grep nagios 看进程是否处于运行状态。到这一步,nagios服务基本上算是配置完毕。做hosts.cfg、services.cfg等配置时,可以运用一些小技巧来减少出错的概率:如先定义少许的主机、服务,待校验无误后再追加。

通过文章详细的描述,我们都应该学会nagios配置,为自己的系统保驾护航!


相关内容