简体   繁体   中英

Reading a shorter than 1 minute load average on a linux system

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?

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.

You could try grabbing a sysstat package and using sar.

http://linux.die.net/man/1/sar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM