当前位置: 首页>>代码示例>>Java>>正文


Java OperatingSystemMXBean.getVersion方法代码示例

本文整理汇总了Java中java.lang.management.OperatingSystemMXBean.getVersion方法的典型用法代码示例。如果您正苦于以下问题:Java OperatingSystemMXBean.getVersion方法的具体用法?Java OperatingSystemMXBean.getVersion怎么用?Java OperatingSystemMXBean.getVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.OperatingSystemMXBean的用法示例。


在下文中一共展示了OperatingSystemMXBean.getVersion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOsInfo

import java.lang.management.OperatingSystemMXBean; //导入方法依赖的package包/类
public static void getOsInfo() {
    OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
    //os general info
    String osName = osBean.getName();
    String osVersion = osBean.getVersion();
    String osArch = osBean.getArch();

    //CPU
    int cores = osBean.getAvailableProcessors();
    String cpuName = System.getenv("PROCESSOR_IDENTIFIER");
    //only on *nix systems
    double loadAvg = osBean.getSystemLoadAverage();

    if (osBean instanceof com.sun.management.OperatingSystemMXBean) {
        getExtendedOsInfo((com.sun.management.OperatingSystemMXBean) osBean);
    }
}
 
开发者ID:games647,项目名称:Java-Snippets,代码行数:18,代码来源:EnvironmentInfo.java

示例2: getJvmSummary

import java.lang.management.OperatingSystemMXBean; //导入方法依赖的package包/类
private JvmSummaryInfo getJvmSummary() {
  OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
  RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();

  JvmSummaryInfo jvmSummary = new JvmSummaryInfo();
  jvmSummary.vmVendor = runtimeBean.getVmVendor();
  jvmSummary.vmName = runtimeBean.getVmName();
  jvmSummary.vmVersion = runtimeBean.getVmVersion();
  jvmSummary.osName = osBean.getName();
  jvmSummary.osVersion = osBean.getVersion();
  jvmSummary.osArch = osBean.getArch();
  jvmSummary.user = System.getProperty("user.name");

  try {
    jvmSummary.host = InetAddress.getLocalHost().getHostName();
  } catch (UnknownHostException e) {
    // Ignored
  }

  jvmSummary.currentWorkingDirectory = path(Paths.get(".").toAbsolutePath().getParent());
  jvmSummary.site = path(sitePath);
  return jvmSummary;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:GetSummary.java

示例3: getOSInfo

import java.lang.management.OperatingSystemMXBean; //导入方法依赖的package包/类
/***
 * Get OS information.
 */
private static void getOSInfo(){
	
	OperatingSystemMXBean osbean = ManagementFactory.getOperatingSystemMXBean();
	osName = osbean.getName();
	osArch = osbean.getArch();
	osVersion = osbean.getVersion();
	cpuUsage = osbean.getSystemLoadAverage();
	availableProcessors = osbean.getAvailableProcessors();

}
 
开发者ID:ParkJinSang,项目名称:Jinseng-Server,代码行数:14,代码来源:ServerStatus.java

示例4: create

import java.lang.management.OperatingSystemMXBean; //导入方法依赖的package包/类
public static OperatingSystemInfo create() {
    OperatingSystemInfo operatingSystemInfo = new OperatingSystemInfo();

    OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();

    operatingSystemInfo.name = operatingSystemMXBean.getName();
    operatingSystemInfo.version = operatingSystemMXBean.getVersion();

    if (SystemUtils.IS_OS_LINUX) {
        operatingSystemInfo.distributionName = resolveLinuxDistributionName();
    }

    operatingSystemInfo.architecture = operatingSystemMXBean.getArch();
    operatingSystemInfo.numberOfLogicalProcessors = operatingSystemMXBean.getAvailableProcessors();

    if (com.sun.management.OperatingSystemMXBean.class.isAssignableFrom(operatingSystemMXBean.getClass())) {
        com.sun.management.OperatingSystemMXBean sunOsMxBean = com.sun.management.OperatingSystemMXBean.class.cast(operatingSystemMXBean);
        operatingSystemInfo.physicalMemorySizeInBytes = sunOsMxBean.getTotalPhysicalMemorySize();
        operatingSystemInfo.swapSpaceSizeInBytes = sunOsMxBean.getTotalSwapSpaceSize();
    }

    Map<String, Long> diskSpaceInBytesByRootPaths = new HashMap<>();
    for (File rootFile : File.listRoots()) {
        diskSpaceInBytesByRootPaths.put(rootFile.getAbsolutePath(), rootFile.getTotalSpace());
    }
    operatingSystemInfo.diskSpaceInBytesByRootPaths = diskSpaceInBytesByRootPaths;

    return operatingSystemInfo;
}
 
开发者ID:centro,项目名称:monitoring-center,代码行数:30,代码来源:OperatingSystemInfo.java

示例5: addVendorInfoJmx

import java.lang.management.OperatingSystemMXBean; //导入方法依赖的package包/类
private void addVendorInfoJmx(UaObjectNode vendorServerInfo) {
    OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
    MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();

    UaVariableNode usedMemory = new UaVariableNode(
        nodeMap,
        new NodeId(1, "VendorServerInfo/UsedMemory"),
        new QualifiedName(1, "UsedMemory"),
        LocalizedText.english("UsedMemory")) {
        @Override
        public DataValue getValue() {
            return new DataValue(new Variant(memoryBean.getHeapMemoryUsage().getUsed() / 1000));
        }
    };
    usedMemory.setDataType(Identifiers.Int64);

    UaVariableNode maxMemory = new UaVariableNode(
        nodeMap,
        new NodeId(1, "VendorServerInfo/MaxMemory"),
        new QualifiedName(1, "MaxMemory"),
        LocalizedText.english("MaxMemory")) {
        @Override
        public DataValue getValue() {
            return new DataValue(new Variant(memoryBean.getHeapMemoryUsage().getMax()));
        }
    };
    maxMemory.setDataType(Identifiers.Int64);

    UaVariableNode osName = new UaVariableNode(
        nodeMap,
        new NodeId(1, "VendorServerInfo/OsName"),
        new QualifiedName(1, "OsName"),
        LocalizedText.english("OsName")) {
        @Override
        public DataValue getValue() {
            return new DataValue(new Variant(osBean.getName()));
        }
    };
    osName.setDataType(Identifiers.String);

    UaVariableNode osArch = new UaVariableNode(
        nodeMap,
        new NodeId(1, "VendorServerInfo/OsArch"),
        new QualifiedName(1, "OsArch"),
        LocalizedText.english("OsArch")) {
        @Override
        public DataValue getValue() {
            return new DataValue(new Variant(osBean.getArch()));
        }
    };
    osArch.setDataType(Identifiers.String);

    UaVariableNode osVersion = new UaVariableNode(
        nodeMap,
        new NodeId(1, "VendorServerInfo/OsVersion"),
        new QualifiedName(1, "OsVersion"),
        LocalizedText.english("OsVersion")) {
        @Override
        public DataValue getValue() {
            return new DataValue(new Variant(osBean.getVersion()));
        }
    };
    osVersion.setDataType(Identifiers.String);

    vendorServerInfo.addComponent(usedMemory);
    vendorServerInfo.addComponent(maxMemory);
    vendorServerInfo.addComponent(osName);
    vendorServerInfo.addComponent(osArch);
    vendorServerInfo.addComponent(osVersion);
}
 
开发者ID:eclipse,项目名称:milo,代码行数:71,代码来源:VendorNamespace.java


注:本文中的java.lang.management.OperatingSystemMXBean.getVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。