當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。