Linux display average CPU load for last week Linux display average CPU load for last week linux linux

Linux display average CPU load for last week


You might want to check out sar (man page), it fits your use case nicely.

System Activity Reporter (SAR) - capture important system performance metrics at periodic intervals.

Example from IBM Developer Works Article:

Add an entry to your root crontab

# Collect measurements at 10-minute intervals0,10,20,30,40,50   * * * *   /usr/lib/sa/sa1# Create daily reports and purge old files0                  0 * * *   /usr/lib/sa/sa2 -A

Then you can simply query this information using a sar command (display all of today's info):

root ~ # sar -A

Or just for a certain days log file:

root ~ # sar -f /var/log/sa/sa16

You can usually find it in the sysstat package for your linux distro


As far as I know it's not stored anywhere... It's a trivial thing to write, anyway. Just add something like

cat /proc/loadavg >> /var/log/loads

to your crontab.

Note that there are monitoring tools (like Munin) which can do this kind of thing for you, and generate pretty graphs of it to boot... they might be overkill for your situation though.


I would recommend looking at Multi Router Traffic Grapher (MRTG).

Using snmpd to read the load average, it will automatically calculate averages at any time interval and length, along with nice charts for analysis.

Someone has already posted a CPU usage example.