/jmxjr

JMX

Primary LanguageRubyMIT LicenseMIT

JMX

DESCRIPTION:

JMX is a library which allows you to access JMX MBeans as a client or create your own MBeans as a Ruby class.

SYNOPSIS:

Connect to same JVM as client script and look at Memory MBean

   require 'jmx'

   client = JMX.simple_connect(:port => 9999)

   memory = client["java.lang:type=Memory"]
   puts memory.attributes

You can also create your own MBeans and register them as well:

   require 'jmx'

   class MyDynamicMBean < RubyDynamicMBean
     rw_attribute :name, :string, "My sample attribute"
     r_attribute :explicit_reader, :int, "Sample int with writer", :my_reader

     operation "Doubles a value"
     parameter :int, "a", "Value to double"
     returns :int
     def double(a)
       a + a
     end
   end

   dyna = MyDynamicMBean.new("domain.MySuperBean", "Heh")
   domain = my_server.default_domain
   my_server.register_mbean dyna, "#{@domain}:type=MyDynamicMBean"

REQUIREMENTS:

  • JRuby

INSTALL:

  • jruby -S gem install jmx

PROBLEMS:

  • Use '-J-Dcom.sun.management.jmxremote' to make jruby process accessible from a jruby command-line