<?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; jvm</title>
	<atom:link href="http://guoyong.org/tag/jvm/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>使用Cacti监控JVM</title>
		<link>http://guoyong.org/2010/01/27/512</link>
		<comments>http://guoyong.org/2010/01/27/512#comments</comments>
		<pubDate>Wed, 27 Jan 2010 08:55:59 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[监控]]></category>
		<category><![CDATA[运维]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=512</guid>
		<description><![CDATA[Cacti官方论坛里有几个监控JVM的模板： http://forums.cacti.net/about19761.html http://forums.cacti.net/post-112268.html 导入到Cacti后，需要启用JVM的SNMP Agent，方法如下： 1. 启动JVM的参数里加入-Dcom.sun.management.snmp.port=9998 这个是指定SNMP Agent的监听端口。 2. 设置访问权限 $ sudo cp $JRE_HOME/lib/management/snmp.acl.template $JRE_HOME/lib/management/snmp.acl$ sudo vi $JRE_HOME/lib/management/snmp.aclacl = {&#160; {&#160;&#160; &#160;communities = public, private&#160;&#160; &#160;access = read-only&#160;&#160; &#160;managers = localhost&#160; }}trap = {&#160; {&#160;&#160; &#160;trap-community = public&#160;&#160; &#160;hosts = localhost&#160; }} 3. 设置配置文件的权限，必须只能为启用JVM的用户只读，否则不能工作。(management.properties不用修改，使用默认配置即可) $ sudo chmod 600 management.properties snmp.acl$ sudo chown jetty management.properties [...]]]></description>
			<content:encoded><![CDATA[<p>Cacti官方论坛里有几个监控JVM的模板：</p>
<ul>
<li><a href="http://forums.cacti.net/about19761.html">http://forums.cacti.net/about19761.html</a></li>
<li>
<a href="http://forums.cacti.net/post-112268.html">http://forums.cacti.net/post-112268.html</a></li>
</ul>
<p>导入到Cacti后，需要启用JVM的SNMP Agent，方法如下：<br />
1. 启动JVM的参数里加入-Dcom.sun.management.snmp.port=9998 这个是指定SNMP Agent的监听端口。<br />
2. 设置访问权限</p>
<div class="hl-surround"><div class="hl-main">$ sudo cp $JRE_HOME/lib/management/snmp.acl.template $JRE_HOME/lib/management/snmp.acl<br />$ sudo vi $JRE_HOME/lib/management/snmp.acl<br /><br />acl = {<br />&nbsp; {<br />&nbsp;&nbsp; &nbsp;communities = public, private<br />&nbsp;&nbsp; &nbsp;access = read-only<br />&nbsp;&nbsp; &nbsp;managers = localhost<br />&nbsp; }<br />}<br /><br />trap = {<br />&nbsp; {<br />&nbsp;&nbsp; &nbsp;trap-community = public<br />&nbsp;&nbsp; &nbsp;hosts = localhost<br />&nbsp; }<br />}</div></div>
<p>3. 设置配置文件的权限，必须只能为启用JVM的用户只读，否则不能工作。(management.properties不用修改，使用默认配置即可)</p>
<div class="hl-surround"><div class="hl-main">$ sudo chmod 600 management.properties snmp.acl<br />$ sudo chown jetty management.properties snmp.acl</div></div>
<p>4. 重启JVM，用netstat命令检查9998端口是否已被监听或用snmpwalk命令检查。</p>
<div class="hl-surround"><div class="hl-main">$ sudo netstat -tlunp |grep 9998<br />$ snmpwalk -v 2c -c public localhost:9998 .1.3.6.1.4.1.42</div></div>
<p>5. 为了让远程的Cacti主机可以访问，可使用snmpd的proxy功能将请求转发到localhost的JVM SNMP Agent上。修改snmpd的配置文件，添加<br />
proxy -v 2c -c public localhost:9998 .1.3.6.1.4.1.42<br />
然后重启snmpd服务。在Cacti主机上以snmpwalk命令检查，应该能得到与上一步中snmpwalk命令一样的输出。snmpwalk -v 2c -c public remotehost .1.3.6.1.4.1.42<br />
6. 至此，可以在Cacti里为JVM主机添加监控图表了，注意Device的SNMP Options配置里SNMP Version要选择Version 2。</p>
<p>参考：</p>
<ul>
<li><a href="http://java.sun.com/javase/6/docs/technotes/guides/management/snmp.html">http://java.sun.com/javase/6/docs/technotes/guides/management/snmp.html</a></li>
<li>
<a href="http://www.fifi.org/cgi-bin/man2html/usr/share/man/man5/snmpd.conf.5snmp.gz">http://www.fifi.org/cgi-bin/man2html/usr/share/man/man5/snmpd.conf.5snmp.gz</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.org/2010/01/27/512/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

