jmx4r 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require "rubygems"
6
6
 
7
7
  dir = File.dirname(__FILE__)
8
8
  lib = File.join(dir, "lib", "jmx4r.rb")
9
- version = "0.0.5"
9
+ version = "0.0.6"
10
10
 
11
11
  task :default => [:test]
12
12
 
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env jruby
2
+ require 'rubygems'
3
+ require 'jmx4r'
4
+ require 'jconsole'
5
+
6
+ mem_pools = JMX::MBean.find_all_by_name "java.lang:type=MemoryPool,*"
7
+ mem_pools.each do |pool|
8
+ puts pool.object_name["name"]
9
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env jruby
2
+ require 'rubygems'
3
+ require 'jmx4r'
4
+
5
+ # This example shows how to iterate on TabularData
6
+
7
+ runtime = JMX::MBean.find_by_name "java.lang:type=Runtime"
8
+
9
+ # The system_properties attribute of the Runtime MBean is an instance of
10
+ # TabularDataSupport
11
+ sysprops = runtime.system_properties
12
+ sysprops.each do | sysprop|
13
+ puts "#{sysprop["key"]} = #{sysprop["value"]}"
14
+ end
@@ -36,9 +36,9 @@ EOCMD
36
36
  if pwd_file and access_file
37
37
  cmd << " -J-Dcom.sun.management.jmxremote.password.file=#{pwd_file}"
38
38
  cmd << " -J-Dcom.sun.management.jmxremote.access.file=#{access_file}"
39
- end
39
+ end
40
40
  Thread.start { system cmd }
41
- sleep 4
41
+ sleep 1
42
42
  end
43
43
 
44
44
  # Stop an instance of JConsole (by killing its process)
@@ -48,7 +48,7 @@ EOCMD
48
48
  def JConsole.stop(port=3000)
49
49
  jconsole_pid = `ps a -w -o pid,command | grep -w jconsole | grep port=#{port} | grep -v grep | grep -v ruby | cut -c -5`
50
50
  `kill #{jconsole_pid}` if jconsole_pid != ""
51
- sleep 3
51
+ sleep 1
52
52
  end
53
53
  end
54
54
 
@@ -16,6 +16,7 @@ end
16
16
 
17
17
  module JMX
18
18
  require 'open_data_helper'
19
+ require 'objectname_helper'
19
20
  require 'jruby'
20
21
 
21
22
  class MBean
@@ -0,0 +1,21 @@
1
+ # Copyright 2008 Jeff Mesnil (http://jmesnil.net)
2
+ #
3
+ # This file adds methods to ObjectName proxies
4
+ require 'java'
5
+
6
+ JavaUtilities.extend_proxy('javax.management.ObjectName') do
7
+ def key?(k)
8
+ self.contains_key k
9
+ end
10
+ alias has_key? key?
11
+ alias include? key?
12
+ alias member? key?
13
+
14
+ def keys
15
+ self.get_key_property_list.key_set
16
+ end
17
+
18
+ def [](key)
19
+ self.get_key_property key
20
+ end
21
+ end
@@ -27,4 +27,14 @@ JavaUtilities.extend_proxy('javax.management.openmbean.CompositeDataSupport') do
27
27
  def [](key)
28
28
  self.get key
29
29
  end
30
+ end
31
+
32
+ JavaUtilities.extend_proxy('javax.management.openmbean.TabularDataSupport') do
33
+ include Enumerable
34
+ def each
35
+ self.values.each do |value|
36
+ yield value
37
+ end
38
+ self
39
+ end
30
40
  end
metadata CHANGED
@@ -3,17 +3,20 @@ extensions: []
3
3
  homepage: http://code.google.com/p/jmx4r/
4
4
  executables: []
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.5
6
+ version: 0.0.6
7
7
  post_install_message:
8
- date: 2008-04-11 22:00:00 +00:00
8
+ date: 2008-07-31 22:00:00 +00:00
9
9
  files:
10
10
  - examples/class_loading.rb
11
11
  - examples/jvm_mngmt.rb
12
12
  - examples/logging.rb
13
13
  - examples/memory.rb
14
14
  - examples/memory_on_many_nodes.rb
15
+ - examples/memory_types.rb
16
+ - examples/runtime_sysprops.rb
15
17
  - lib/jconsole.rb
16
18
  - lib/jmx4r.rb
19
+ - lib/objectname_helper.rb
17
20
  - lib/open_data_helper.rb
18
21
  - test/tc_attributes.rb
19
22
  - test/tc_auth.rb