本文整理匯總了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);
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}