{"id":380,"date":"2013-05-03T16:11:22","date_gmt":"2013-05-03T08:11:22","guid":{"rendered":"http:\/\/www.sulabs.net\/?p=380"},"modified":"2020-08-28T18:38:02","modified_gmt":"2020-08-28T10:38:02","slug":"%e4%bd%bf%e7%94%a8cacti-%e7%9b%91%e6%8e%a7jvm","status":"publish","type":"post","link":"https:\/\/www.sulabs.net\/?p=380","title":{"rendered":"\u4f7f\u7528Cacti \u76d1\u63a7JVM"},"content":{"rendered":"<p>\u4ee5\u4e0b\u64cd\u4f5c\u5728CentOS 6.4 X64, net-snmp-5.5-44, JDK 1.6.43, Tomcat 7.0.39 \u73af\u5883\u4e0b\u9a8c\u8bc1\u901a\u8fc7.<\/p>\n<p>1.\u4e3aJRE\u521b\u5efaSNMP ACL\u89c4\u5219\uff0c $JAVA_HOME \u4e3aJDK\u5b89\u88c5\u8def\u5f84\uff0c\u5728managment \u76ee\u5f55\u4e0b\u6709 \u73b0\u6210template\u7684\u6a21\u677f\u6587\u4ef6\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u3002<\/p>\n<pre class=\"brush: shell; gutter: true\">vim $JAVA_HOME\/jre\/lib\/management\/snmp.acl<\/pre>\n<p>\u5185\u5bb9\u5982\u4e0b<br \/>\n<!--more--><\/p>\n<pre class=\"brush: bash; gutter: true\">#The communities public and private are allowed access from the local host.\r\nacl = {\r\n        {\r\n           communities = public, private\r\n           access = read-only\r\n           managers = localhost\r\n        }\r\n}\r\n\r\n# Traps are sent to localhost only\r\ntrap = {\r\n         {\r\n            trap-community = public\r\n            hosts = localhost\r\n         }\r\n}<\/pre>\n<p>2.\u91cd\u547d\u540dpassword \u6587\u4ef6,JRE\u542f\u52a8\u65f6\u4f1a\u68c0\u6d4b\u6b64\u6587\u4ef6\uff0c\u56e0\u524d\u9762\u7684\u89c4\u5219\u6307\u5b9a\u4e86Trap\u4e3a\u672c\u673a\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u5355\u72ec\u505a\u5b89\u5168\u914d\u7f6e. mv jmxremote.password.template jmxremote.password<\/p>\n<p>3.\u4fee\u6539\u6587\u4ef6\u6743\u9650\uff0c\u907f\u514d\u8fd0\u884c\u65f6\u65e0\u6cd5\u8bfb\u53d6\u914d\u7f6e<\/p>\n<pre class=\"brush: shell; gutter: true\">chmod 400 snmp.acl \r\nchmod 400 jmxremote.password<\/pre>\n<p>(\u5982\u679ctomcat\u4f7f\u7528jsvc\u5b88\u62a4\u8fdb\u7a0b\uff0c\u6216\u5176\u5b83JVM\u5e94\u7528\uff0c\u4ee5\u975eroot\u7528\u6237\u8fd0\u884c\uff0c\u8fd9\u91cc\u7684 snmp.acl \u9700\u8981\u7ed9\u4e88\u8be5\u7528\u6237\u8bbf\u95ee\u6743\u9650)<\/p>\n<p>4.\u4fee\u6539tomcat \u542f\u52a8\u53c2\u6570 vim $TOMCAT_HOME\/bin\/catalina.sh<\/p>\n<p>\u5728\u811a\u672c\u6587\u4ef6\u5f00\u5934\u90e8\u5206\u6ce8\u91ca\u7ed3\u675f\u540e\u6dfb\u52a0\u4e00\u884c\u53c2\u6570,\u7528\u6765\u542f\u52a8JRE\u7684SNMP\uff0c\u5e76\u4f7f\u7528\u7aef\u53e3162 \u9ed8\u8ba4\u8bfb\u53d6 $JAVA_HOME\/jre\/lib\/management\/ \u4e0b\u7684\u914d\u7f6e\uff0c\u65e0\u9700\u989d\u5916\u6dfb\u52a0\u5176\u5b83\u914d\u7f6e.<\/p>\n<p>JAVA_OPTS=\"-Dcom.sun.management.snmp.port=162\"<\/p>\n<p>5.\u4e3aSNMP\u6dfb\u52a0\u4ee3\u7406<\/p>\n<p>vim \/etc\/snmpd\/snmpd.conf \u5728\u6587\u4ef6\u5c3e\u90e8\u6dfb\u52a0 proxy -v 2c -c public localhost:162 .1.3.6.1.4.1.42<\/p>\n<p>\u5e76\u91cd\u542fsnmp\u670d\u52a1<\/p>\n<p>6.\u6d4b\u8bd5\u548c\u9a8c\u8bc1 \u542f\u52a8Tomcat \u5e76\u9a8c\u8bc1 162\u7aef\u53e3\u662f\u5426\u6b63\u5e38\u5f00\u542f\uff0c\u5982\u679c\u4e0d\u6b63\u5e38\uff0c\u9700\u68c0\u67e5\u65e5\u5fd7\uff0c\u4e00\u822c\u90fd\u662f snmp.acl \u6587\u4ef6\u6743\u9650\u9519\u8bef\u5bfc\u81f4\u3002<\/p>\n<p>\u9a8c\u8bc1JVM SNMP\u4fe1\u606f\u662f\u5426\u6b63\u5e38\u8f93\u51fa,\u8fd9\u91cc\u7684SNMP\u7248\u672c\uff0c\u7528\u6237\u540d\u5bc6\u7801\u90fd\u540cCacti<\/p>\n<p>snmpwalk -v 3 -u SNMP\u7528\u6237\u540d -a MD5 -A \"SNMP\u5bc6\u7801\" -l authNoPriv 127.0.0.1 .1.3.6.1.4.1.42<\/p>\n<p>7.\u5bfc\u5165JVM\u76d1\u63a7\u6a21\u677f\u3002<br \/>\n\u5b98\u65b9\u4e0b\u8f7d <a href=\"http:\/\/forums.cacti.net\/post-112268.html\">http:\/\/forums.cacti.net\/post-112268.html<\/a><br \/>\n\u672c\u5730\u4e0b\u8f7d\uff1a<a href=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2013\/05\/jvm_templates.rar\">jvm_templates<\/a><\/p>\n<p>8.\u4fee\u6539\u6570\u636e\u6a21\u677f\u7aef\u53e3\u53f7 \u56e0\u5bfc\u5165\u7684\u6a21\u677f\u5355\u72ec\u5b9a\u4e49\u4e86\u7aef\u53e3\u53f7\uff0c\u9700\u8981\u4fee\u6539\u4e3aCacti\u6b63\u5e38\u4f7f\u7528\u7684SNMP\u7aef\u53e3\u53f7\uff0c\u9ed8\u8ba4\u4e3a161 (\u975eJRE\u7684SNMP\u7aef\u53e3\u53f7) \u5426\u5219\u65e0\u6cd5\u91c7\u96c6\u5230\u6570\u636e<\/p>\n<p>\u5728Cacti &gt; Templates &gt; Data Templates \u4e2d\u627e\u5230jvm\u5f00\u5934\u7684\u6570\u636e\u6a21\u677f\uff0c\u8fdb\u53bb\u540e\u5728 Custom Data \u4e2d\u5c06\u6307\u5b9a\u7684SNMP Port \u53bb\u6389\u4fdd\u5b58\u5373\u53ef<\/p>\n<p>9.\u4e3a\u76d1\u63a7\u7684\u670d\u52a1\u5668\u8bbe\u5907\u6dfb\u52a0\u5173\u8054\u7684JVM\u56fe\u5f62\u6a21\u677f\uff0c\u6216\u76f4\u63a5\u9009\u62e9 JVM HOST \u5373\u53ef,\u4e0b\u9762\u662f\u793a\u4f8b\u3002<\/p>\n<p><a href=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2013\/05\/jvm_mon.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-382 alignnone\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2013\/05\/jvm_mon.jpg\" alt=\"jvm_mon\" width=\"647\" height=\"824\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2013\/05\/jvm_mon.jpg 647w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2013\/05\/jvm_mon-235x300.jpg 235w\" sizes=\"auto, (max-width: 647px) 100vw, 647px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u64cd\u4f5c\u5728CentOS 6.4 X64, net-snmp-5.5-44, JD &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/www.sulabs.net\/?p=380\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[54,68,88,89],"class_list":["post-380","post","type-post","status-publish","format-standard","hentry","category-linux","tag-cacti","tag-jvm","tag-snmp","tag-89"],"_links":{"self":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=380"}],"version-history":[{"count":4,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions"}],"predecessor-version":[{"id":970,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions\/970"}],"wp:attachment":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}