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