npc安装问题解决一例

CactiNagios都是好用的运维监控软件,NPC(Nagios Plugin for Cacti)是一个Cacti插件,安装后可以在Cacti界面里使用Nagios的功能。官方安装文档在这里

我的安装环境是这样的:

PHP必须安装PDO 和 JSON扩展。由于NPC使用了Ext JS,如果没有JSON扩展,NPC的界面不会出来,只能看到一个空白页面。Ubuntu 6.06下安装PDO可以参考这里

按照官方文档安装配置好后,遇到了没有显示任何数据的问题,host, hostgroup, service, servicegroup等等都看不到。

检查了NPC的数据库表,有数据,说明NDOUtils已经工作。没有出现在界面上,说明是NPC从数据库读出来到界面显示过程中出现的问题。

用Firebug找出NPC界面为了获取显示数据的Ajax请求(比如/cacti/plugins/npc/npc.php?module=servicegroups&action=getHostStatusPortlet),直接在浏览器里访问,可以看到出了异常:Fatal error: Uncaught exception ‘Doctrine_Exception’ with message ‘Couldn’t find class NpcServicegroups’ 。显然是Doctrine没有加载到NPC定义的领域类。

经过一番对Doctrine的调试,发现原因在Doctrine类的loadModels方法(Line 516 in Doctrine.php)

$e = explode('.', $file->getFileName());

这里getFileName返回了带绝对路径的文件名,导致autoload函数失败。改成下面这样就解决了。

$e = explode('.', basename($file->getFileName()));

不过还是不明白为什么getFileName返回的是带绝对路径的文件名,是跟我的系统环境有关系吗?有熟悉PHP的朋友能解释一下就好了。

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.
For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>