Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.21 KB

README.md

File metadata and controls

57 lines (37 loc) · 1.21 KB

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.connect(:host => 'localhost', :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

   my_server = JMX::MBeanServer.new
   my_server_connector = JMX.simple_server(server: my_server)

   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