Log CPU usage over time

Soldato
Joined
4 Dec 2002
Posts
3,978
Location
Bourne, Lincs
I have had a look and the command top is mentioned, but after a simple guide to be able to run a program and log the CPU usages of it.

I can not have the task manager up as the program runs full screen

Kimbie
 
Desktop gadget whilst running the app in windowed mode?

If you can't run it windowed, there are some programs that allow you to log data to a .csv file, which you can then turn into a graph using Microsoft Excel.
 
Would load averages suffice? If so, you could write a quick bash script to write `uptime` to a file and call it every x minutes with cron...
 
The sar program from the sysstat package does exactly what you want and logs loads over time. Install it and make sure the sysstat daemon is running. By default it logs the CPU ever 10 mins but that will be configurable.

Sample output on my box, set it to take 5 readings, every 5 seconds and send it out to a file or whatever:

Code:
[root@tcore rc.d]# sar -u 5 5
Linux 2.6.37-ARCH (tcore) 	25/02/11 	_x86_64_	(12 CPU)

20:01:28        CPU     %user     %nice   %system   %iowait    %steal     %idle
20:01:33        all      0.11      0.00      0.06      0.02      0.00     99.81
20:01:38        all      0.32      0.00      0.05      0.00      0.00     99.62
20:01:43        all      0.02      0.00      0.00      0.00      0.00     99.98
20:01:48        all      0.10      0.00      0.05      0.02      0.00     99.84
20:01:53        all      0.08      0.00      0.08      0.02      0.00     99.82
Average:        all      0.13      0.00      0.05      0.01      0.00     99.82
 
Suggestion above has my vote. If you want something a little more graphical and visual also maybe more stats have a look at munin. Its a monitoring agent that will publish results to a local web server and draw graphs. Very usefully and easy to set up compared to most solutions.
 
collectl as an alternative to sar, its much nicer. Supporting utility like Colplot provides the easy graphical bit.

Alternatively, consider Ganglia or Nagios perhaps. Collectl is very lightweight though.
 
Back
Top Bottom