How do I analyze my CPU usage over a long period of time?

I am just wondering if there's any Ubuntu app that can track my CPU usage.

The problem is that I am currently using a quad core i5, whilst what I do most in daily usage is just browsing and rails developing.

So I want an app that can analyse my CPU usage so that I can decide switching back to a dual core i3.

Thanks.


Solution 1:

So I want an app that can analyse my CPU usage

The easiest way for your purposes is to log the CPU load (usage), and then analyze yourself (e.g. with LibreOffice Calc) to find out.

  • /proc/loadavg contains the CPU's average load for the last 1, 5 and 15 minutes, in the form: 0.91 0.48 0.62 3/357 16607 (the first three numbers are what matter)
  • You can log this to a text file, say every fifteen minutes, by making it a cron-job.
  • To do this system-wide, edit /etc/crontab and add this line:
*/15 *    * * *   root    cat /proc/loadavg >> /home/your-username/cpu-load.log
  • You can set to 1 or 5 minutes instead by changing the first parameter to * or */5 instead of */15

  • After a few days of normal use, you can import the log file as text/CSV into LibreOffice Calc, and plot the appropriate column (third for 15 minutes), to see your average load.

If your load doesn't go above 2.00 for any lengthy period of time, that means you can make do with a dual-core processor instead of your current quad-core.


There are many network-based monitoring tools, e.g. Munin, MRTG, Cacti, etc. which can be installed from the repositories, will do the logging and even generate pretty graphs for you, but those are complete overkill for what you need. :-)

Solution 2:

How about:

vmstat 1 > vmstat.log

consult "man vmstat" to see the meanings of the fields.