-1

I need to find the CPU usage as Total, used and Free. Memory usage Total used and Free of a deployed application in websphere application server .

And I want to find this by a programatic way Could someone help me on this which API I need to use for this

Is server capable of doing this ? If not How to track the resources of the process as a whole. I need to do this in a programatic way ? Could you please suggest any API for this

user1920
  • 89
  • 1
  • 2
  • 11
  • 1
    The JVM (and likely operating system) is not capable of tracking resources of an application running within a JVM process. You can only track the resources of the process as a whole. Is that what you meant to ask instead? – Brett Kail Dec 29 '15 at 19:02
  • HI @Brett Kail, Thanks for your reply. Is server capable of doing this ? If not How to track the resources of the process as a whole. I need to do this in a programatic way ? Could you please suggest any API for this – user1920 Dec 30 '15 at 05:19

1 Answers1

1

You can get info about the JVM as a whole, or per thread, but (AFAIK) not per application.

In Java 6 you can:

OperatingSystemMXBean o = ManagementFactory.getOperatingSystemMXBean();
double load = o.getSystemLoadAverage();
int processors = o.getAvailableProcessors();

ThreadMXBean t = ManagementFactory.getThreadMXBean();
int threads = t.getThreadCount();
int maxThreads = t.getPeakThreadCount();
for (long id : t.getAllThreadIds()) {
  long cpuTime = t.getThreadCpuTime(id);
}

Java 7 offers more detailed info, but probably not what exactly what you want.