<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>wolfg&#039;s Weblog &#187; Doctrine</title>
	<atom:link href="http://guoyong.me/tag/doctrine/feed/" rel="self" type="application/rss+xml" />
	<link>http://guoyong.me</link>
	<description>wolfg&#039;s journey with open source, linux, programming, sysadm ...</description>
	<lastBuildDate>Wed, 04 Apr 2012 12:42:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/cn/</creativeCommons:license>		<item>
		<title>npc安装问题解决一例</title>
		<link>http://guoyong.me/linux/sysadm/npc%e5%ae%89%e8%a3%85%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3%e4%b8%80%e4%be%8b/</link>
		<comments>http://guoyong.me/linux/sysadm/npc%e5%ae%89%e8%a3%85%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3%e4%b8%80%e4%be%8b/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 12:27:34 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[监控]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[运维]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[npc]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=504</guid>
		<description><![CDATA[Cacti和Nagios都是好用的运维监控软件，NPC(Nagios Plugin for Cacti)是一个Cacti插件，安装后可以在Cacti界面里使用Nagios的功能。官方安装文档在这里。 我的安装环境是这样的： Ubuntu 6.06 LTS PHP 5.1.2 Cacti 0.8.7e Cacti Plugin Architecture 2.6 Nagios 3.2.0 NDOUtils 1.4b7 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&#038;action=getHostStatusPortlet)，直接在浏览器里访问，可以看到出了异常：Fatal error: Uncaught exception &#8216;Doctrine_Exception&#8217; with message &#8216;Couldn&#8217;t find class &#8230; <a href="http://guoyong.me/linux/sysadm/npc%e5%ae%89%e8%a3%85%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3%e4%b8%80%e4%be%8b/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cacti.net/">Cacti</a>和<a href="http://www.nagios.org/">Nagios</a>都是好用的运维监控软件，<a href="http://trac2.assembla.com/npc/">NPC</a>(Nagios Plugin for Cacti)是一个Cacti插件，安装后可以在Cacti界面里使用Nagios的功能。官方安装文档在<a href="http://trac2.assembla.com/npc/wiki/QuickStartGuide">这里</a>。</p>
<p>我的安装环境是这样的：</p>
<ul>
<li>Ubuntu 6.06 LTS</li>
<li>PHP 5.1.2</li>
<li>Cacti 0.8.7e</li>
<li><a href="http://cactiusers.org/downloads/">Cacti Plugin Architecture 2.6</a></li>
<li>Nagios 3.2.0</li>
<li>NDOUtils 1.4b7</li>
</ul>
<p>PHP必须安装PDO 和 JSON扩展。由于NPC使用了Ext JS，如果没有JSON扩展，NPC的界面不会出来，只能看到一个空白页面。Ubuntu 6.06下安装PDO可以参考<a href="http://bhiv.com/getting-pdo-to-work-with-ubuntus-606-lts-dapper-drake/">这里</a>。</p>
<p>按照官方文档安装配置好后，遇到了没有显示任何数据的问题，host, hostgroup, service, servicegroup等等都看不到。</p>
<p>检查了NPC的数据库表，有数据，说明NDOUtils已经工作。没有出现在界面上，说明是NPC从数据库读出来到界面显示过程中出现的问题。</p>
<p>用Firebug找出NPC界面为了获取显示数据的Ajax请求(比如/cacti/plugins/npc/npc.php?module=servicegroups&#038;action=getHostStatusPortlet)，直接在浏览器里访问，可以看到出了异常：Fatal error: Uncaught exception &#8216;Doctrine_Exception&#8217; with message &#8216;Couldn&#8217;t find class NpcServicegroups&#8217; 。显然是Doctrine没有加载到NPC定义的领域类。</p>
<p>经过一番对Doctrine的调试，发现原因在Doctrine类的loadModels方法(Line 516 in Doctrine.php)</p>
<div class="hl-surround"><div class="hl-main"><span style="color: #00008b;">$e</span><span style="color: Gray;"> = </span><span style="color: Blue;">explode</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">.</span><span style="color: #8b0000;">'</span><span style="color: Gray;">, </span><span style="color: #00008b;">$file</span><span style="color: Gray;">-&gt;</span><span style="color: Blue;">getFileName</span><span style="color: Olive;">())</span><span style="color: Gray;">;</span></div></div>
<p>这里getFileName返回了带绝对路径的文件名，导致autoload函数失败。改成下面这样就解决了。</p>
<div class="hl-surround"><div class="hl-main"><span style="color: #00008b;">$e</span><span style="color: Gray;"> = </span><span style="color: Blue;">explode</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">.</span><span style="color: #8b0000;">'</span><span style="color: Gray;">, </span><span style="color: Blue;">basename</span><span style="color: Olive;">(</span><span style="color: #00008b;">$file</span><span style="color: Gray;">-&gt;</span><span style="color: Blue;">getFileName</span><span style="color: Olive;">()))</span><span style="color: Gray;">;</span></div></div>
<p>不过还是不明白为什么getFileName返回的是带绝对路径的文件名，是跟我的系统环境有关系吗？有熟悉PHP的朋友能解释一下就好了。</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/linux/sysadm/npc%e5%ae%89%e8%a3%85%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3%e4%b8%80%e4%be%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.448 seconds -->

