前一段时间应公司要求部署nagios监控系统,一切安装配置就绪,在启动nagios的过程中遇到了问题,仔细查看nagios的日志并没有发现具体的问题在哪里,使用/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg对nagios主配置文件的语法做检查时,看到如下所示的提示信息:

Website: http://www.nagios.org

Reading configuration data...

  Read main config file okay...

Processing object config file '/usr/local/nagios/etc/hosts.cfg'...

Processing object config file '/usr/local/nagios/etc/services.cfg'...

Processing object config file '/usr/local/nagios/etc/commands.cfg'...

Processing object config file '/usr/local/nagios/etc/contacts.cfg'...

Processing object config file '/usr/local/nagios/etc/timeperiods.cfg'...

Processing object config file '/usr/local/nagios/etc/templates.cfg'...

Error: Invalid host object directive '    action_url'.

Error: Could not add object property in file '/usr/local/nagios/etc/templates.cfg' on line 193.

  Error processing object config files!



经过仔细的排除后,找到了导致问题出现的原因,由于这个文件中追加的内容有误所导致

解决方式:

vi /usr/local/nagios/etc/templates.cfg

define host{

       name    hosts-pnp

       register        0

       action_url      /nagios/pnp/index.php?host=$HOSTNAME$

       process_perf_data       1

}

define service{

       name    services-pnp

       register        0

       action_url      /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$

       process_perf_data       1

}