Example usage for java.lang.management ManagementFactory getRuntimeMXBean

List of usage examples for java.lang.management ManagementFactory getRuntimeMXBean

Introduction

In this page you can find the example usage for java.lang.management ManagementFactory getRuntimeMXBean.

Prototype

public static RuntimeMXBean getRuntimeMXBean() 

Source Link

Document

Returns the managed bean for the runtime system of the Java virtual machine.

Usage

From source file:io.github.jeddict.jcode.util.JavaUtil.java

public static double getJavaVersion() {
    return Double.parseDouble(ManagementFactory.getRuntimeMXBean().getSpecVersion());
}

From source file:org.apache.gobblin.util.JvmUtils.java

/**
 * Gets the input arguments passed to the JVM.
 * @return The input arguments./*  w  w  w  .  j a va 2 s. c  o m*/
 */
public static String getJvmInputArguments() {
    RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
    List<String> arguments = runtimeMxBean.getInputArguments();
    return String.format("JVM Input Arguments: %s", JOINER.join(arguments));
}

From source file:ro.nextreports.server.web.debug.InfoUtil.java

public static List<String> getJVMArguments() {
    RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
    return runtimeBean.getInputArguments();
}

From source file:tk.jomp16.plugin.utils.uptime.Uptime.java

@Command("uptime")
public void uptime(CommandEvent commandEvent) {
    commandEvent.respond("Uptime: " + DurationFormatUtils
            .formatDurationWords(ManagementFactory.getRuntimeMXBean().getUptime(), true, false));
}

From source file:org.apache.geode.internal.process.ProcessUtils.java

/**
 * Returns the pid for this process./*from w  w w . j  av  a2s .c om*/
 * 
 * @throws PidUnavailableException if parsing the pid from the name of the RuntimeMXBean fails
 * 
 * @see java.lang.management.RuntimeMXBean#getName()
 */
public static int identifyPid() throws PidUnavailableException {
    return identifyPid(ManagementFactory.getRuntimeMXBean().getName());
}

From source file:ro.nextreports.server.web.debug.InfoUtil.java

public static List<Info> getGeneralJVMInfo() {
    List<Info> infos = new ArrayList<Info>();

    RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
    infos.add(new Info("uptime", "" + Duration.milliseconds(runtimeBean.getUptime()).toString()));
    infos.add(new Info("name", runtimeBean.getName()));
    infos.add(new Info("pid", runtimeBean.getName().split("@")[0]));

    OperatingSystemMXBean systemBean = ManagementFactory.getOperatingSystemMXBean();
    infos.add(new Info("os name", "" + systemBean.getName()));
    infos.add(new Info("os version", "" + systemBean.getVersion()));
    infos.add(new Info("system load average", "" + systemBean.getSystemLoadAverage()));
    infos.add(new Info("available processors", "" + systemBean.getAvailableProcessors()));

    ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
    infos.add(new Info("thread count", "" + threadBean.getThreadCount()));
    infos.add(new Info("peak thread count", "" + threadBean.getPeakThreadCount()));

    MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
    infos.add(new Info("heap memory used",
            FileUtils.byteCountToDisplaySize(memoryBean.getHeapMemoryUsage().getUsed())));
    infos.add(new Info("non-heap memory used",
            FileUtils.byteCountToDisplaySize(memoryBean.getNonHeapMemoryUsage().getUsed())));

    return infos;
}

From source file:com.alibaba.wasp.util.ServerCommandLine.java

/**
 * Log information about the currently running JVM.
 *//*from  w w  w  .  j a  v a2 s  . c om*/
public static void logJVMInfo() {
    // Print out vm stats before starting up.
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    if (runtime != null) {
        LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + runtime.getVmVendor() + ", vmVersion="
                + runtime.getVmVersion());
        LOG.info("vmInputArguments=" + runtime.getInputArguments());
    }
}

From source file:se.ivankrizsan.messagecowboy.MessageCowboy.java

private static void logProcessIdAndHost() {
    final String[] thePidAndHost = ManagementFactory.getRuntimeMXBean().getName().split("@");

    LOGGER.info("Process id: {}", thePidAndHost[0]);
    LOGGER.info("Host: {}", thePidAndHost[1]);
}

From source file:com.netflix.genie.agent.AgentMetadataImpl.java

private static String getAgentPidOrFallback() {
    final String jvmId = ManagementFactory.getRuntimeMXBean().getName();
    final Matcher pidPatternMatcher = Pattern.compile("(\\d+)@.*").matcher(jvmId);
    if (pidPatternMatcher.matches() && !StringUtils.isBlank(pidPatternMatcher.group(1))) {
        return pidPatternMatcher.group(1);
    }// ww w .j  a  va  2 s .  c  o m
    log.warn("Failed to retrieve agent PID (JVM id: {})", jvmId);
    return FALLBACK_STRING;
}

From source file:com.gopivotal.cloudfoundry.test.core.RuntimeUtils.java

public RuntimeUtils() {
    this(System.getenv(), ManagementFactory.getRuntimeMXBean(), System.getProperties());
}