0

I want to get performance of storage system using Netapp API and Java.

I am able to fetch volumes, Aggregates, Disks info.

Now I want to get memory and CPU utilization of a system. Which class should I use in order to get information related to CPU and memory?

I use apirunner object to call various classes in API.
Here is a code for a connection..

Protocol protocol = Protocol.INSECURE_HTTPS;
try {
    ApiRunner apirunner = new ApiRunner(ApiTarget.builder()
        .withHost(myip)
        .withUserName(user)
        .withPassword(pass)
        .withTargetType(TargetType.FILER)
        .useProtocol(protocol)
        .build()
    );
Vishwas
  • 6,967
  • 5
  • 42
  • 69

1 Answers1

0

From Google and a possible duplicate of this question:

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
}

Here is the duplicate post: How to monitor the computer's cpu, memory, and disk usage in Java?

Keep in mind though, that this uses the SIGAR API

Community
  • 1
  • 1
ylun.ca
  • 2,504
  • 7
  • 26
  • 47