Search in sources :

Example 1 with RuntimeInfo

use of com.shulie.instrument.simulator.module.model.runtime.RuntimeInfo in project LinkAgent by shulieTech.

the class RuntimeModule method info.

@Command(value = "info", description = "获取JVM运行时信息")
public CommandResponse info(final Map<String, String> args) {
    try {
        final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        final ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();
        RuntimeInfo runtimeInfo = new RuntimeInfo();
        runtimeInfo.setTotalLoadedClassCount(classLoadingMXBean.getTotalLoadedClassCount());
        runtimeInfo.setLoadedClassCount(classLoadingMXBean.getLoadedClassCount());
        runtimeInfo.setUnloadedClassCount(classLoadingMXBean.getUnloadedClassCount());
        runtimeInfo.setVerbose(classLoadingMXBean.isVerbose());
        runtimeInfo.setName(runtimeMXBean.getName());
        runtimeInfo.setStartTime(runtimeMXBean.getStartTime());
        runtimeInfo.setManagementSpecVersion(runtimeMXBean.getManagementSpecVersion());
        runtimeInfo.setSpecName(runtimeMXBean.getSpecName());
        runtimeInfo.setSpecVersion(runtimeMXBean.getSpecVersion());
        runtimeInfo.setSpecVendor(runtimeMXBean.getSpecVendor());
        runtimeInfo.setVmName(runtimeMXBean.getVmName());
        runtimeInfo.setVmVersion(runtimeMXBean.getVmVersion());
        runtimeInfo.setVmVendor(runtimeMXBean.getVmVendor());
        runtimeInfo.setInputArguments(runtimeMXBean.getInputArguments());
        runtimeInfo.setClassPath(runtimeMXBean.getClassPath());
        runtimeInfo.setBootClassPath(runtimeMXBean.getBootClassPath());
        runtimeInfo.setLibraryPath(runtimeMXBean.getLibraryPath());
        runtimeInfo.setOsName(System.getProperty("os.name"));
        runtimeInfo.setOsVersion(System.getProperty("os.version"));
        runtimeInfo.setJavaVersion(System.getProperty("java.version"));
        runtimeInfo.setJavaHome(System.getProperty("java.home"));
        runtimeInfo.setSystemLoadAverage(ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage());
        runtimeInfo.setProcessors(ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors());
        runtimeInfo.setArch(ManagementFactory.getOperatingSystemMXBean().getArch());
        runtimeInfo.setUptime(runtimeMXBean.getUptime() / 1000);
        return CommandResponse.success(runtimeInfo);
    } catch (Throwable e) {
        return CommandResponse.failure(e);
    }
}
Also used : RuntimeInfo(com.shulie.instrument.simulator.module.model.runtime.RuntimeInfo) ClassLoadingMXBean(java.lang.management.ClassLoadingMXBean) RuntimeMXBean(java.lang.management.RuntimeMXBean) Command(com.shulie.instrument.simulator.api.annotation.Command)

Aggregations

Command (com.shulie.instrument.simulator.api.annotation.Command)1 RuntimeInfo (com.shulie.instrument.simulator.module.model.runtime.RuntimeInfo)1 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)1 RuntimeMXBean (java.lang.management.RuntimeMXBean)1