Reputation: 3753
How to track system load average using java.The result should be same the load average is returning form the 'uptime' command in Linux.
Sample uptime command result is,
root@jamsheer:~# uptime
16:01:06 up 6:58, 2 users, load average: 1.24, 1.25, 1.33
I need to get same load average through programmatically and should be executable at all platforms, Any suggestion, please.
Thanks in advance.
Upvotes: 2
Views: 1861
Reputation: 7620
For platform independent result, check JMX and OperatingSystemMXBean
:
OperatingSystemMXBean mxBean = ManagementFactory.getOperatingSystemMXBean();
double loadAverage = mxBean.getSystemLoadAverage();
Please mind that if your platform is unable to report it, the value returned will be negative, which is the result in my case on Win 7 box.
Upvotes: 2