Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux display average CPU load for last week

Tags:

On a Linux box, I need to display the average CPU utilisation per hour for the last week. Is that information logged somewhere? Or do I need to write a script that wakes up every 15 minutes to copy /proc/loadavg to a logfile?

EDIT: I'm not allowed to use any tools other than those that come with Linux.

like image 905
thornate Avatar asked Feb 10 '09 06:02

thornate


People also ask

How do I check my CPU load average?

We can get CPU load average via either debug or running command of "top", "uptime", and run command "lscpu" to get CPU core info and compare, if CPU is overloaded, we can suggest kill pending processes, restart product, or add more CPU/cores.

What are the commands to check load average on Linux system?

However, the easiest, most standardized way to see your load average is to run the uptime command in a terminal. This command shows your computer's load average as well as how long it's been powered on. The uptime command works on Linux, Mac OS X, and other Unix-like systems.


1 Answers

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 intervals 0,10,20,30,40,50   * * * *   /usr/lib/sa/sa1 # Create daily reports and purge old files 0                  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

like image 123
Brian Gianforcaro Avatar answered Nov 17 '22 00:11

Brian Gianforcaro