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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With