Class: JMX::MBean
- Inherits:
-
Object
- Object
- JMX::MBean
- Defined in:
- lib/liquid/ext/jmx4r.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.to_tree ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/liquid/ext/jmx4r.rb', line 10 def self.to_tree find_all_by_name("*:*").inject({}) do |result, mbean| domain = mbean.object_name.domain properties = mbean.object_name.key_property_list_string.split(',') mresult = result[domain] ||= {} mresult = mresult[properties.shift] ||= {} until properties.empty? mbean.to_h(mresult) result end end |
Instance Method Details
#get_value(key) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/liquid/ext/jmx4r.rb', line 30 def get_value(key) case value = send(key) when Java::JavaxManagementOpenmbean::CompositeDataSupport Hash[value.to_a].symbolize_keys when Enumerable value.to_a else value end rescue RuntimeMBeanException => e raise unless e.cause.is_a?(UnsupportedOperationException) nil end |
#to_h(hsh = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/liquid/ext/jmx4r.rb', line 21 def to_h(hsh = {}) attributes.keys.inject(hsh) do |result, key| result[key.to_sym] = get_value(key) result end.merge!({ object_name: object_name.to_s, }) end |