我正在从 Nagios 3.2.3 迁移到 4.02,但一直出现一条不明确的错误消息:有没有办法从 Nagios Core 中获取更多详细信息?从附加的错误输出中,我无法找到任何线索,甚至无法找到哪个 .cfg 文件是罪魁祸首。
/usr/local/nagios/bin/nagios -vvvvvv /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.0.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 11-25-2013
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/etc/nagios/objects/contacts.cfg'...
Processing object config file '/etc/nagios/objects/escalations.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/signal-hosts.cfg'...
Processing object config file '/etc/nagios/objects/servicechecks.cfg'...
Processing object config file '/etc/nagios/objects/passivechecks.cfg'...
Processing object config file '/etc/nagios/objects/websites/aws1-checkwebservices.cfg'...
Processing object config file '/etc/nagios/objects/websites/aws2-checkwebservices.cfg'...
Processing object config file '/etc/nagios/objects/websites/awscabot-checkwebservices.cfg'...
Processing object config file '/etc/nagios/objects/others.cfg'...
Error processing object config files!
***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
答案1
启用调试输出并将级别设置为 2 或 3 (DEBUGL_FUNCTIONS 和 DEBUGL_CONFIG)。
(查看源代码后,我最初认为这是一个权限问题的想法是错误的;对于“无法读取目标文件”问题有一个特定的错误消息。)
如果调试输出中没有任何有用的信息,您可以尝试通过 运行它strace
。如果这不是一个选项,或者没有帮助,您将不得不对源代码进行一些破解以获取更多信息。
如果你确实想这样做:
您的错误是非常普遍的错误,由(base/nagios.c
第 435-438 行)引起:
/* read object config files */
result = read_all_object_data(config_file);
if(result != OK) {
printf(" Error processing object config files!\n\n");
此函数(在中base/config.c
)仅设置一个选项标志,然后调用read_object_config_data()
,返回通用错误。
该函数(在common/objects.c
)实际上只是调用xodtemplate_read_config_data
。
真正的工作是在xodtemplate_read_config_data
(在xdata/xodtemplate.x
)中完成的。因此,如果您想添加一些额外的调试输出,那么您可能应该在那里进行操作。