|
|
|||||
Arun Gupta's Blog
«TOTD #61: How to locally manage/monitor your Rails/Merb applications on JRuby/GlassFish using JMX ? |
Main
| TOTD #63: jmx4r gem - How to manage/monitor your Rails/Merb applications on JRuby/GlassFish ? »
TOTD #62: How to remotely manage/monitor your Rails/Merb applications on JRuby/GlassFish using JMX API ?Posted by arungupta on January 08, 2009 at 10:21 AM | Comments (0)TOTD #61 showed how to manage/monitor a Rails/Merb application running using JRuby/GlassFish using standard Java tools. Both the application and the management tools are running on the same machine. But that's never the case in a production environment. Instead remote management of an application is required when running in production mode. Fortunately, similar set of tools can be used for remote management as well. However the underlying Java Virtual Machine needs to be configured to enable remote monitoring. This is achieved by setting JAVA_OPTS environment variables as shown below: Set up the following envinronment variable before running the Rails/Merb application:
The first property enables the JMX remote agent (aka MBeans server) and local monitoring. The second property configures the port number for remote management using JMX/RMI connections. The third and fourth properties, for simplicity only, disable access control and SSL for remote monitoring. It is highly recommended to use them in a production environment. Using Password Authentication provide more details about configuring passwords for access control. Using SSL provide more details about configuring SSL. Now for a Rails/Merb application running on GlassFish all the MBeans are also available on the JMX agent running on port 8686. This agent can be accessed using the standard URL as shown below:
"192.168.124.1" is the host's IP address on which the Rails/Merb application is running and "8686" is the port configured in JAVA_OPTS. More details about the URL are available here. First, lets use jconsole on a different machine to monitor this application. Start jconsole by typing the command in a shell as:
In the "New Connection" window, select "Remote Process" and enter the URL defined above as shown below: ![]() And then the management data snapshot is captured as shown below: ![]() And here is a snapshot from a remote Solaris machine: ![]() Notice the URL, as opposed to "pid", is shown on the jconsole window. This indicates that remote connection is being used instead of local process id. TOTD #61 further explains how jconsole can be used to manage/monitor your Rails/Merb applications. As mentioned in TOTD #61, JRuby runtime exposes 4 different MBeans - ClassCache, Config, JITCompiler and ParserStats - all in "org.jruby" domain. Lets write a client application that query these MBeans to monitor the state of JRuby runtime and perform some management actions based upon the returned results. Here is the Ruby client code using Java Management Extensions (JMX) APIs.
Here are the main tasks achieved by this code:
Each JRuby-exposed MBean has multiple attributes that can be utilized to monitor your application and take appropriate actions. For example, an application could detect low memory and stop accepting new connections. And you can continue to use GlassFish for running your Rails and Merb applications (now Sinatra as well)! Subsequent blogs in this series will discuss:
Technorati: totd glassfish jruby rubyonrails merb jmx manage monitor Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment | |||||
|
|