I want a script to tell me the average CPU usage over the past 5 minutes (and repeat every 5 minutes, likely as a cron job).
/proc/stat
just has counters since system start, and I want to avoid developing a full program to parse and sample that. top
seems to just report usage over the moment (second?) before it displays/writes the table.
sysstat/sar looks promising, but looks like I'll always loose the midnight value looking at what sar -u
gives me…
Best Answer
You want to look at
/proc/loadavg
. The first three fields are the one-minute, five-minute, and fifteen-minute load averages. For a built-in utility, look at theuptime
command.