Module: JMX

Defined in:
lib/jmx.rb,
lib/jmx/server.rb,
lib/jmx/version.rb,
lib/jmx/dynamic_mbean.rb,
lib/jmx.rb

Defined Under Namespace

Modules: JavaTypeAware, MBeans Classes: Attribute, MBeanProxy, MBeanServer, MBeanServerConnector, NoSuchBeanError, ObjectName, Operation, Parameter

Constant Summary collapse

VERSION =
"0.6"

Class Method Summary collapse

Class Method Details

.connect(opts = {}) ⇒ Object

Connect to a MBeanServer opts can contain several values

:host - The hostname where the server resides (def: localhost)
:port - Which port the server resides at (def: 8686)
:url_path - path part of JMXServerURL (def: /jmxrmi)
:user - User to connect as (optional)
:password - Password for user (optional)


54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/jmx.rb', line 54

def self.connect(opts = {})
  host = opts[:host] || 'localhost'
  port = opts[:port] || 8686
  url_path = opts[:url_path] || "/jmxrmi"
  url = "service:jmx:rmi:///jndi/rmi://#{host}:#{port}#{url_path}"

  if opts[:user]
    JMX::MBeanServer.new url, opts[:user], opts[:password]
  else
    JMX::MBeanServer.new url
  end
end

.simple_server(opts = {}) ⇒ Object

sad little simple server setup so you can connect up to it.



70
71
72
73
74
75
76
# File 'lib/jmx.rb', line 70

def self.simple_server(opts = {})
  port = opts[:port] || 8686
  url_path = opts[:url_path] || "/jmxrmi"
  url = "service:jmx:rmi:///jndi/rmi://localhost:#{port}#{url_path}"
  $registry = RMIRegistry.new port
  @connector = JMX::MBeanServerConnector.new(url, JMX::MBeanServer.new).start
end