{"id":160,"date":"2012-10-04T20:39:04","date_gmt":"2012-10-04T18:39:04","guid":{"rendered":"http:\/\/blog.johannes-beck.name\/?p=160"},"modified":"2013-05-17T22:22:40","modified_gmt":"2013-05-17T20:22:40","slug":"jmx-monitoring-for-jboss-as-7-with-munin","status":"publish","type":"post","link":"https:\/\/blog.johannes-beck.name\/?p=160","title":{"rendered":"JMX monitoring for JBoss AS 7 with Munin"},"content":{"rendered":"<p>Continuing the last story how to setup the basic monitoring cases for JBoss AS 7 with Munin, I took the next step to enhance the monitoring in Munin by reading JMX values from the server. If you have setup and configured JBoss AS 7 correctly, you can access JMX with the jconsole application; but JBoss AS 7 comes with a different JMX transport, so as the first step, make sure you start <i>$JBOSS_HOME\/bin\/jconsole.sh<\/i>.<\/p>\n<p>Choose remote process and enter <a href=\"service:jmx:remoting-jmx:\/\/HOST:PORT\">service:jmx:remoting-jmx:\/\/HOST:PORT<\/a>, where HOST is the hostname or IP of your server, port defaults to 9999. As username and password you need to enter the values you have configured in <i>mgmt-users.properties<\/i>.<\/p>\n<p>With this setup working, I had a look on the JMX plugin in Munin, and discovered it needs to be enhanced to support the different protocol JBoss has introduced for JMX. Currently it only supports the MI\/JNDI based access. Before going into details what I changed, and how you can get the changes, here is the final setup:<\/p>\n<p>In <i>\/etc\/munin\/plugin-conf.d\/munin-node<\/i> we will add a new chapter for JMX:<\/p>\n<p><code><br \/>\n[jmx_*]<br \/>\nenv.ip HOST<br \/>\nenv.port PORT<br \/>\nenv.username USER<br \/>\nenv.password PASS<br \/>\n<\/code><\/p>\n<p>Make sure to replace the constants with your values. Additionally you may need to install an additional package for the java support in munin (on Fedora \/ Centos you need to <i>yum install munin-java-plugins<\/i>).<\/p>\n<p>In <i>\/etc\/munin\/plugins\/<\/i> the <i>jmx_<\/i> executable needs to be linked to a munin probe.<\/p>\n<p><code><br \/>\nln -s \/usr\/share\/munin\/plugins\/jmx_ jmx_Threads<br \/>\n<\/code> <\/p>\n<p>Now you can test it with <i>munin-run jmx_Threads -d<\/i> and will see that you can&#8217;t connect to the JXM server in JBoss AS 7. As said before the munin plugin can not yet handle the jmx-remote protocol.<\/p>\n<p>Looking add the code in the JMX plugin, it uses the given IP and port to build the URL to connect to. We need to override this with our own url, so we need to have one new parameter, which replaces the ip and port: env.url takes the full URL to the JMX port. And because the jmx-remoting protocol needs additionally libraries &#8211; this is why there is an extra startup script for jconsole in the JBoss distribution &#8211; we need a second parameter env.classpath to add JARs to the classpath.<\/p>\n<p><code><br \/>\n[jmx_*]<br \/>\nenv.url service:jmx:remoting-jmx:\/\/HOST:PORT<br \/>\nenv.port PORT<br \/>\nenv.username USER<br \/>\nenv.password PASS<br \/>\nenv.classpath jboss-logging.jar:jboss-marshalling.jar:jboss-marshalling-river.jar:jboss-remoting.jar:jboss-remoting-jmx.jar:xnio-api.jar:xnio-nio.jar<br \/>\n<\/code><\/p>\n<p>I&#8217;ve forked the munin codebase to <a href=\"https:\/\/github.com\/kifj\/munin\">https:\/\/github.com\/kifj\/munin<\/a>, in <i>plugins\/javalib<\/i> and <i>plugins\/node.d.java<\/i> you&#8217;ll find the changed files. <\/p>\n<p>As a result the <i>jmx_<\/i> script and the <i>munin-jmx-plugins.jar<\/i> are handling the additional parameters. You can build it yourself or download the 2 files from here: <a href=\"http:\/\/johannes-beck.name\/binary\/jmx_\">jmx_<\/a> and <a href=\"http:\/\/johannes-beck.name\/binary\/munin-jmx-plugins.jar\">munin-jmx-plugins.jar<\/a>. These need to replace the original files in <i>\/usr\/share\/munin\/plugins\/jmx_<\/i> and <i>\/usr\/share\/java\/munin-jmx-plugins.jar<\/i>. The libraries from env.classpath need to copied or symlinked to <i>\/usr\/share\/java<\/i> too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuing the last story how to setup the basic monitoring cases for JBoss AS 7 with Munin, I took the next step to enhance the monitoring in Munin by reading JMX values from the server. If you have setup and configured JBoss AS 7 correctly, you can access JMX with the jconsole application; but JBoss [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,43,3],"tags":[61,17,24,25,21],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-java","category-jboss-as7","category-software-development","tag-java","tag-jboss-as-7","tag-jmx","tag-jmx-remote","tag-munin"],"_links":{"self":[{"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160"}],"version-history":[{"count":9,"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":297,"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions\/297"}],"wp:attachment":[{"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.johannes-beck.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}