Search |
|||||
TOTD #63: jmx4r gem - How to manage/monitor your Rails/Merb applications on JRuby/GlassFish ?Posted by arungupta on January 13, 2009 at 10:54 AM PST
TOTD #61 and TOTD #62 shows how to use JMX APIs to locally/remotely manage/monitor your Rails/Merb applications. This Tip Of The Day extends TOTD #62 and shows how remote management can be done using jmx4r gem. This gem provides a clean mapping between JMX APIs and Ruby. It allows to write pure Ruby code to manage/monitor any Rails application. As a result it removes all dependency on the Java code used in TOTD #62. Lets first install the gem!
Here is the equivalent Ruby code to flush the class cache (as in TOTD #62):
As with all Ruby code, really clean and simple! The key parts of the code are highlighted in bold. "JMX::MBean.establish_connection" establishes a connection with a JMX agent running on a remote machine identified by the IP address and port number specified. "JMX::MBean.find_all_by_name" queries the agent for all the MBeans in "org.jruby" domain. And then the code is self explanatory. Just dump this code in a file and run it as:
to see the output similar to:
Make sure Rails/Merb application is running after setting JAVA_OPTS as described in TOTD #62. For this blog, the JMX agent/Rails application ran on a Mac and the JMX client on a Solaris box. The jmxr examples provides some more ways to use the gem. There is also jmx gem that provides similar functionality. It even allows to create MBeans and provides a simple server where they can be registered. Tom's blog provide more details on usage and there is even a sample included. Subsequent blogs in this series will discuss:
Technorati: totd glassfish jruby rubyonrails merb jmx jmx4r manage monitor »
Related Topics >>
Glassfish Comments
Comments are listed in date ascending order (oldest first)
|
|||||
|
|