Reputation: 15122
On a linux system, your standard uptime command returns the following:
6.46, 6.00, 4.51
As most of you will probably know, these correspond to 1, 5 and 15 minute load averages.
I was wondering if it were possible to either pull from somewhere ( /proc/ ... ? ) or manually parse ( ps aux? ) out a more real time snapshot of the systems load average?
Can this be parsed / pulled from anywhere?
Upvotes: 0
Views: 520
Reputation: 10579
You could watch /proc/uptime, which contains the cpu time spent doing something vs. total time. By monitoring this repeatedly, you can effectively acquire samples for any EWMA window of your choosing.
Or, if you like a challenge, you can obtain old_loadavg_value
and new_loadavg_value
from /proc/loadavg and solve the linear system
new_loadavg1_value = alpha_1 * old_loadavg1_value + (1-alpha_1) * new_sample
new_loadavg5_value = alpha_5 * old_loadavg5_value + (1-alpha_5) * new_sample
new_loadavg15_value = alpha_15 * old_loadavg15_value + (1-alpha_15) * new_sample
for new_sample
, and then do the calculation forwards again with an alpha
reflecting your desired window.
Upvotes: 2
Reputation: 6246
You could try grabbing a sysstat package and using sar.
http://linux.die.net/man/1/sar
Upvotes: 0