[root@bogon ~]# /usr/sbin/nagios -v /etc/nagios/nagios.cfg
Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/etc/nagios/objects/commands.cfg'...
Processing object config file '/etc/nagios/objects/contacts.cfg'...
Processing object config file '/etc/nagios/objects/timeperiods.cfg'...
Processing object config file '/etc/nagios/objects/templates.cfg'...
Processing object config file '/etc/nagios/objects/localhost.cfg'...
Processing object config file '/etc/nagios/objects/switch.cfg'...
Processing object config directory '/etc/nagios/conf.d'...
Read object config files okay...
Running pre-flight check on configuration data...
Checking services...
Checked 16 services.
Checking hosts...
Checked 3 hosts.
Checking host groups...
Checked 2 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 25 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
七、问题总结
1.安装过程很顺利,但是在配置完成后,重启nagios服务时出现报错,大概意思就是配置文件错误,请检查配置文件(Invalid object definition type ' host' in file '/etc/nagios/objects/template)。使用/usr/sbin/nagios -v /etc/nagios/nagios.cfg命令检查,发现templates.cfg 文件配置错误,后来一直检查也没发现问题,最后发现问题出在字体格式上面,因为我是直接从网页上复制黏贴的,服务器可能无法识别字体或者特殊符号(手动敲一遍,问题解决。。。汗)
2.nagios重启完成后,登录网页,可以看到如下图所示,点击网络表格的图表,没有弹出页面图表,报错信息如下:"/var/lib/pnp4nagios/localhost" for host "localhost" does not exist,将commands.cfg更改为上面的内容后,重启nagios恢复正常(我出错之前的配置并不是这样的),重启完要等一会才能看到图的。
3.将服务迁移到生产机器时(之前是在测试机上进行测试的),发现配置完成后,打开网页,点击图标图标时,弹出的页面提示:The requested URL /pnp4nagios/index.php/graph was not found on this server.提示页面无法找到。
解决方法:打开vim /etc/httpd/conf.d/pnp4nagios.conf,将里面的代码完全拷贝,打开vim /etc/httpd/conf/httpd.conf,将拷贝的代码粘贴到文件的最下方,然后重启nagios和apache服务。
[root@m ~]# service nagios restart
[root@m ~]# service httpd restart