Java Code Examples for com.sun.management.DiagnosticCommandMBean#invoke()

The following examples show how to use com.sun.management.DiagnosticCommandMBean#invoke() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NMTHelper.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 2
Source File: DcmdUtil.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    try {
        System.out.print("> " + cmd + " ");
        for (String s : args) {
            System.out.print(s + " ");
        }
        System.out.println(":");
        String result = (String) dcmd.invoke(transform(cmd), dcmdArgs, signature);
        System.out.println(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 3
Source File: NMTHelper.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 4
Source File: NMTHelper.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 5
Source File: DcmdUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    try {
        System.out.print("> " + cmd + " ");
        for (String s : args) {
            System.out.print(s + " ");
        }
        System.out.println(":");
        String result = (String) dcmd.invoke(transform(cmd), dcmdArgs, signature);
        System.out.println(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 6
Source File: NMTHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 7
Source File: DcmdUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    try {
        System.out.print("> " + cmd + " ");
        for (String s : args) {
            System.out.print(s + " ");
        }
        System.out.println(":");
        String result = (String) dcmd.invoke(transform(cmd), dcmdArgs, signature);
        System.out.println(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 8
Source File: NMTHelper.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 9
Source File: NMTHelper.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 10
Source File: NMTHelper.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 11
Source File: NMTHelper.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    try {
        System.out.print("> " + cmd + " ");
        for (String s : args) {
            System.out.print(s + " ");
        }
        System.out.println(":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        System.out.println(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 12
Source File: NMTHelper.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    try {
        System.out.print("> " + cmd + " ");
        for (String s : args) {
            System.out.print(s + " ");
        }
        System.out.println(":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        System.out.println(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 13
Source File: NMTHelper.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 14
Source File: NMTHelper.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
Example 15
Source File: NMTHelper.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static String executeDcmd(String cmd, String ... args) {
    DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean();
    Object[] dcmdArgs = {args};
    String[] signature = {String[].class.getName()};

    String cmdString = cmd + " " +
        Arrays.stream(args).collect(Collectors.joining(" "));
    File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
    System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
    try (FileWriter fw = new FileWriter(f)) {
        fw.write("> " + cmdString + ":");
        String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
        fw.write(result);
        return result;
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    return null;
}