Sha256: ea9d0ac1ff0d049d0df59b463cd72094376003c3bde4f564c853e6183fab77ae

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

module JConsole
    def JConsole.start(port=3000) 
        cmd =<<-EOCMD.split("\n").join(" ")
            jconsole
            -J-Dcom.sun.management.jmxremote 
            -J-Dcom.sun.management.jmxremote.port=#{port} 
            -J-Dcom.sun.management.jmxremote.ssl=false 
            -J-Dcom.sun.management.jmxremote.authenticate=false
        EOCMD

        Thread.start { system cmd } 
        sleep 2
    end

    def JConsole.stop()
        jconsole_pid = `ps a -o pid,command | grep -w jconsole |  grep -v grep | grep -v ruby | cut -c -5`
        `kill #{jconsole_pid}` if jconsole_pid != ""
        sleep 2
    end
end

if ARGV.length == 1
    case ARGV[0]
    when "start"
        JConsole::start
        puts "started jconsole"
    when "stop"
        JConsole::stop
        puts "stopped jconsole"
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmx4r-0.0.1 lib/jconsole.rb