[英]how to get performance of CPU and Memory using Netapp API and Java?
我想使用Netapp API和Java獲得存儲系統的性能。
我能夠獲取卷,聚合,磁盤信息。
現在,我想獲取系統的內存和CPU利用率。 我應該使用哪個類來獲取與CPU和內存有關的信息?
我使用apirunner對象來調用API中的各種類。
這是連接的代碼。
Protocol protocol = Protocol.INSECURE_HTTPS;
try {
ApiRunner apirunner = new ApiRunner(ApiTarget.builder()
.withHost(myip)
.withUserName(user)
.withPassword(pass)
.withTargetType(TargetType.FILER)
.useProtocol(protocol)
.build()
);
來自Google以及該問題的可能重復項:
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
private static void printUsage() {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
for (Method method : operatingSystemMXBean.getClass().getDeclaredMethods()) {
method.setAccessible(true);
if (method.getName().startsWith("get")
&& Modifier.isPublic(method.getModifiers())) {
Object value;
try {
value = method.invoke(operatingSystemMXBean);
} catch (Exception e) {
value = e;
} // try
System.out.println(method.getName() + " = " + value);
} // if
} // for
}
這是重復的帖子: 如何在Java中監視計算機的cpu,內存和磁盤使用情況?
但是請記住,這使用了SIGAR API
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.