Project

jmx

0.01
No commit activity in last 3 years
No release in over 3 years
Access and create MBeans in a friendly Ruby syntax
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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