Monitoring CPU Process Usage

SABowling at dstsystems.com SABowling at dstsystems.com
Wed Nov 13 16:33:52 CST 2002


Well, eventually my search for a CPU Process Usage monitor lead me to the
BSD Process Accounting already written into the kernel (assuming it was
enabled during compile.. mine wasn't).  So I recompiled the kernel and
downloaded 'pacct' from sourcefourge and I've got a somewhat usable process
usage monitor.

I'm not extremely happy with it right now, so I might start digging into
the source to see what I can come up with.  It's seems very elementary but
it does what I ask.  I'd rather have a better front end to the actually
reading of the accounting file though, especially something I can read in
perl (because I'm rather new to C/C++).

Thanks for the help!
Scott

--------------------------------------------------------------------------------

Scott Bowling
Analyst Programmer
DST Systems
816.435.4447
SABowling at dstsystems.com

                                                                                                
                    Duane Attaway                                                               
                    <dattaway at attaway.net>       To:     Scott Bowling                          
                    Sent by:                      <sbowling at bowlingkyler.com>                   
                    owner-kclug at marauder.i       cc:     Kansas City Linux Users Group Mailing  
                    lliana.net                    List <kclug at kclug.org>                        
                                                 Subject:     Re: Monitoring CPU Process Usage  
                                                                                                
                    11/11/2002 05:01 AM                                                         
                                                                                                
                                                                                                

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