Skip to content

Instantly share code, notes, and snippets.

@FilBot3
Last active December 5, 2015 08:01
Show Gist options
  • Select an option

  • Save FilBot3/5998987c12369f6ad669 to your computer and use it in GitHub Desktop.

Select an option

Save FilBot3/5998987c12369f6ad669 to your computer and use it in GitHub Desktop.
jmx4r example.
CMD="get -b java.lang:type=Memory HeapMemoryUsage"
echo $CMD | java -jar jmxterm-1.0-alpha-4-uber.jar -l localhost:1099 -n
#!/usr/bin/env ruby
#
# https://github.com/jmesnil/jmx4r
# This script can only be ran with JRuby
#
require 'rubygems'
require 'jmx4r'
JMX::MBean.establish_connection :host => "localhost", :port => "1099"
memory = JMX::MBean.find_by_name "java.lang:type=Memory"
puts memory.heap_memory_usage['used']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment