Search in sources :

Example 36 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project Mycat_plus by coderczp.

the class EnvironmentInformation method getJvmStartupOptions.

/**
 * Gets the system parameters and environment parameters that were passed to the JVM on startup.
 *
 * @return The options passed to the JVM on startup.
 */
public static String getJvmStartupOptions() {
    try {
        final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
        final StringBuilder bld = new StringBuilder();
        for (String s : bean.getInputArguments()) {
            bld.append(s).append(' ');
        }
        return bld.toString();
    } catch (Throwable t) {
        return UNKNOWN;
    }
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean)

Example 37 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project traccar by traccar.

the class Log method logSystemInfo.

public static void logSystemInfo() {
    try {
        OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
        Log.info("Operating system" + " name: " + operatingSystemBean.getName() + " version: " + operatingSystemBean.getVersion() + " architecture: " + operatingSystemBean.getArch());
        RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
        Log.info("Java runtime" + " name: " + runtimeBean.getVmName() + " vendor: " + runtimeBean.getVmVendor() + " version: " + runtimeBean.getVmVersion());
        MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
        Log.info("Memory limit" + " heap: " + memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024) + "mb" + " non-heap: " + memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024) + "mb");
        Log.info("Character encoding: " + System.getProperty("file.encoding") + " charset: " + Charset.defaultCharset());
    } catch (Exception error) {
        Log.warning("Failed to get system info");
    }
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean) RuntimeMXBean(java.lang.management.RuntimeMXBean) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) IOException(java.io.IOException)

Example 38 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project mlib by myshzzx.

the class Oss method getPid.

/**
 * get current process id.
 */
public static int getPid() {
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    String name = runtimeMXBean.getName();
    int idx = name.indexOf('@');
    return Integer.parseInt(name.substring(0, idx));
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean)

Example 39 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project jmeter-plugins-manager by undera.

the class ChangesMaker method getRestartFile.

public File getRestartFile(LinkedList<String> additionalJMeterOptions) throws IOException {
    File file = File.createTempFile("jpgc-restart-", ".list");
    try (PrintWriter out = new PrintWriter(file)) {
        out.print(SafeDeleter.getJVM() + "\n");
        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        List<String> jvmArgs = runtimeMXBean.getInputArguments();
        for (String arg : jvmArgs) {
            out.print(arg + "\n");
        }
        out.print("-jar\n");
        out.print(getJMeterStartCommand(additionalJMeterOptions));
        return file;
    }
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 40 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project wicket by apache.

the class Threads method dumpAllThreads.

/**
 * Creates a dump of all the threads' state and stack traces similar to what JVM produces when
 * signal SIGQUIT is send to the process on Unix machine.
 * <p>
 * Note: This is a best effort to dump as much information as possible because the Java API
 * doesn't provide means to get all the information that is produced by jstack program for
 * example.
 * </p>
 *
 * @param logger
 *            the logger where the collected information will be written
 */
public static void dumpAllThreads(Logger logger) {
    Args.notNull(logger, "logger");
    if (!logger.isWarnEnabled()) {
        return;
    }
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    StringBuilder dump = new StringBuilder();
    dump.append("Full thread dump ").append(runtimeMXBean.getVmName()).append('(').append(runtimeMXBean.getVmVersion()).append(')');
    logger.warn(dump.toString());
    Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
    for (Entry<Thread, StackTraceElement[]> entry : allStackTraces.entrySet()) {
        dumpSingleThread(logger, entry.getKey(), entry.getValue());
    }
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean)

Aggregations

RuntimeMXBean (java.lang.management.RuntimeMXBean)164 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)27 IOException (java.io.IOException)17 MemoryMXBean (java.lang.management.MemoryMXBean)16 ThreadMXBean (java.lang.management.ThreadMXBean)13 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)11 Date (java.util.Date)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 MemoryUsage (java.lang.management.MemoryUsage)8 Method (java.lang.reflect.Method)8 Map (java.util.Map)8 Properties (java.util.Properties)6 InputStream (java.io.InputStream)5 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)5 Iterator (java.util.Iterator)5 File (java.io.File)4 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)4 Field (java.lang.reflect.Field)4 UnknownHostException (java.net.UnknownHostException)4