From 0eb3672642882a1aea333b7f4b1a223caf13df1e Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 29 Apr 2009 12:19:40 -0700 Subject: [PATCH] add mx -jconsole option --- .../java/src/org/hyperic/sigar/cmd/Mx.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java index 554fddf9..642464ae 100644 --- a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java +++ b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java @@ -79,18 +79,38 @@ public class Mx extends SigarCommandBase { } } + private void jconsole() { + String pid = String.valueOf(this.sigar.getPid()); + String[] argv = { "jconsole", pid }; + println("exec(jconsole, " + pid + ")"); + try { + Process p = Runtime.getRuntime().exec(argv); + p.waitFor(); + println("jconsole exited"); + } catch (Exception e) { + println(e.getMessage()); + } + } + public void output(String[] args) throws SigarException { MBeanServer server = getMBeanServer(); register(server); - boolean hasQuery = args.length != 0; - try { - String query; - if (hasQuery) { - query = args[0]; + boolean hasQuery = false; + boolean launchJconsole = false; + String query = "sigar:*"; + + for (int i=0; i