Monitoring CPU Process Usage
Duane Attaway
dattaway at attaway.net
Mon Nov 11 11:01:06 CST 2002
On Sun, 10 Nov 2002, Scott Bowling wrote:
> Would it be possible to write some sort of process monitoring system
> that is capable of retrieving this information after the process ends
> (or maybe right before the process ends)?
There is a nifty little utility called time. It calculates resources used
by the following program. For example, if I wanted to know how much time
it took to check my disk usage:
dattaway at satellite portage $ time df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda2 28241692 21261976 5545112 80% /
tmpfs 1024 196 828 20% /mnt/.init.d
attaway.net:/ 157076808 128794768 20302960 87% /t
real 0m0.078s
user 0m0.000s
sys 0m0.000s
It took 78 milliseconds of time between invocation and termination. CPU
and SYS time were insignificant in this case. You can even format time's
output any way you wish for scripting. More about this from the man page.
I often build the kernel followed by the time command to see how long it
takes:
cd /usr/src/linux
time make bzImage
If I remember right, VMS did this sort of stuff when you submitted jobs.
Pretty cool.
More information about the Kclug
mailing list