<?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; nagios</title>
	<atom:link href="http://guoyong.org/tag/nagios/feed" rel="self" type="application/rss+xml" />
	<link>http://guoyong.org</link>
	<description>wolfg&#039;s journey with open source, linux, programming, sysadm ...</description>
	<lastBuildDate>Thu, 04 Aug 2011 15:02:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/cn/</creativeCommons:license>		<item>
		<title>nrpe使用一例</title>
		<link>http://guoyong.org/2010/01/28/548</link>
		<comments>http://guoyong.org/2010/01/28/548#comments</comments>
		<pubDate>Thu, 28 Jan 2010 07:22:25 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[监控]]></category>
		<category><![CDATA[运维]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[nrpe]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=548</guid>
		<description><![CDATA[NRPE的作用是在远程主机上运行Nagios插件，以便监控远程主机。 Ubuntu Server下安装NRPE很方便： $ sudo apt-get install nagios-nrpe-server nagios-plugins 默认的几个检查命令(check_users, check_load等)都已经在/etc/naigos/nrpe.cfg和/etc/nagios/nrpe_local.cfg配置好了。在Nagios里配置监控服务使用类似如下的监控命令就可以了： check_command&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;check_nrpe!check_load 如果需要自定义监控命令，只需在/etc/nagios/nrpe_local.cfg里设置，重启NRPE服务，再在Nagios里配置监控服务即可。比如，要添加一个监控TCP各种状态的命令，步骤如下： @remotehost$ cd /usr/lib/nagios/plugins$ sudo wget http://www.tuschy.com/nagios/plugins/check_tcp_count$ sudo chmod +x check_tcp_count$ cd /etc/nagios$ sudo vi nrpe_local.cfgcommand[check_tcp_count]=/usr/lib/nagios/plugins/check_tcp_count$ sudo service nagios-nrpe-server restart@nagioshost$ sudo vi remotehost.cfgdefine service{&#160;&#160; &#160; &#160; &#160;use&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>NRPE的作用是在远程主机上运行Nagios插件，以便监控远程主机。</p>
<p>Ubuntu Server下安装NRPE很方便：</p>
<div class="hl-surround"><div class="hl-main">$ sudo apt-get install nagios-nrpe-server nagios-plugins</div></div>
<p>默认的几个检查命令(check_users, check_load等)都已经在/etc/naigos/nrpe.cfg和/etc/nagios/nrpe_local.cfg配置好了。在Nagios里配置监控服务使用类似如下的监控命令就可以了：</p>
<div class="hl-surround"><div class="hl-main">check_command&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;check_nrpe!check_load</div></div>
<p>如果需要自定义监控命令，只需在/etc/nagios/nrpe_local.cfg里设置，重启NRPE服务，再在Nagios里配置监控服务即可。比如，要添加一个监控TCP各种状态的命令，步骤如下：</p>
<div class="hl-surround"><div class="hl-main">@remotehost<br />$ cd /usr/lib/nagios/plugins<br />$ sudo wget http://www.tuschy.com/nagios/plugins/check_tcp_count<br />$ sudo chmod +x check_tcp_count<br />$ cd /etc/nagios<br />$ sudo vi nrpe_local.cfg<br />command[check_tcp_count]=/usr/lib/nagios/plugins/check_tcp_count<br />$ sudo service nagios-nrpe-server restart<br /><br />@nagioshost<br />$ sudo vi remotehost.cfg<br />define service{<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;use&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; generic-service<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;host_name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remotehostname<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;service_description&nbsp; &nbsp; &nbsp; &nbsp; Tcp count<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;check_command&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check_nrpe!check_tcp_count<br />}</div></div>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.org/2010/01/28/548/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>npc安装问题解决一例</title>
		<link>http://guoyong.org/2010/01/17/504</link>
		<comments>http://guoyong.org/2010/01/17/504#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 NpcServicegroups&#8217; 。显然是Doctrine没有加载到NPC定义的领域类。 经过一番对Doctrine的调试，发现原因在Doctrine类的loadModels方法(Line 516 in Doctrine.php) $e = explode('.', $file-&#62;getFileName()); 这里getFileName返回了带绝对路径的文件名，导致autoload函数失败。改成下面这样就解决了。 $e = explode('.', basename($file-&#62;getFileName())); [...]]]></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.org/2010/01/17/504/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

