Friday January 09, 2009
TOTD #63: jmx4r gem - How to manage/monitor your Rails/Merb applications on JRuby/GlassFish ?
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!
| ~ >gem
install jmx4r JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed jmx4r-0.0.6 1 gem installed Installing ri documentation for jmx4r-0.0.6... Installing RDoc documentation for jmx4r-0.0.6... |
| require 'rubygems' require 'jmx4r' JMX::MBean.establish_connection :host => "129.145.133.163", :port => 8686 beans = JMX::MBean.find_all_by_name "org.jruby:*" beans.each { |bean| service = bean.object_name["service"] case service when "ClassCache" @cc_mbean = bean when "Config" @c_mbean = bean end } # clear the cache if it's full if @cc_mbean.full printf "JIT Max: %d, JIT Threshold: %d, Class load count: %d\n", @c_mbean.jit_max, @c_mbean.jit_threshold, @cc_mbean.class_load_count @cc_mbean.flush else puts "Class Cache is not full" printf "Loaded: %d, Reused: %d, Live: %d\n", @cc_mbean.class_load_count, @cc_mbean.class_reuse_count, @cc_mbean.live_class_count end |
| jruby main.rb |
| Class Cache is not full Loaded: 76, Reused: 0, Live: 76 |
Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Today's Page Hits: 3692
Total # blog entries: 1002
I prefer local management, I always build my systems without remote management. A security issue, otherwise. :( :)
Posted by Mark on January 10, 2009 at 05:20 PM PST #
Posted by Arun Gupta's Blog on January 13, 2009 at 10:56 AM PST #
Nice, thanks Arun.
I'm still trying to figure out self-management on Glassfish (i.e. installing your own MBeans to fire off when values go outside thresholds). That would avoid the massive pains involved in getting JMX through a firewall.
I'm sure that should be doable with JRuby too, but think that'd be trying to run before I can walk :)
Posted by Dick Davies on January 19, 2009 at 04:18 AM PST #
thank u arun gupta
Posted by sinema izle on March 10, 2009 at 02:04 PM PDT #