Sha256: 7bd64e0bc35a6c5b34e2908f1dc630c9fc93083d5af7ec28f0aa2faddb75fc77
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
if RUBY_PLATFORM == "java" require 'active_support/core_ext/hash/keys' require 'jmx4r' java_import 'javax.management.RuntimeMBeanException' java_import 'java.lang.UnsupportedOperationException' class JMX::MBean 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 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 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 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
liquid-ext-3.5.3 | lib/liquid/ext/jmx4r.rb |
liquid-ext-3.5.2 | lib/liquid/ext/jmx4r.rb |
liquid-ext-3.5.0 | lib/liquid/ext/jmx4r.rb |
liquid-ext-3.4.2 | lib/liquid/ext/jmx4r.rb |