jmx4r 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/examples/memory_types.rb +9 -0
- data/examples/runtime_sysprops.rb +14 -0
- data/lib/jconsole.rb +3 -3
- data/lib/jmx4r.rb +1 -0
- data/lib/objectname_helper.rb +21 -0
- data/lib/open_data_helper.rb +10 -0
- metadata +5 -2
data/Rakefile
CHANGED
@@ -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
|
data/lib/jconsole.rb
CHANGED
@@ -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
|
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
|
51
|
+
sleep 1
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
data/lib/jmx4r.rb
CHANGED
@@ -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
|
data/lib/open_data_helper.rb
CHANGED
@@ -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.
|
6
|
+
version: 0.0.6
|
7
7
|
post_install_message:
|
8
|
-
date: 2008-
|
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
|