From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,d3b0bb900900167d X-Google-Attributes: gid111c93,public From: Tony Hammitt Subject: Re: ps aux (oddity) Date: 2000/07/28 Message-ID: <39820FB3.1D48F02E@kc.rr.com>#1/1 X-Deja-AN: 651985488 Content-Transfer-Encoding: 7bit References: <3981B9DA.26EB98BE@okstate.edu> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@rr.com X-Trace: typhoon.kc.rr.com 964825012 24.163.146.164 (Fri, 28 Jul 2000 17:56:52 CDT) MIME-Version: 1.0 Reply-To: tony@hammitt.com NNTP-Posting-Date: Fri, 28 Jul 2000 17:56:52 CDT Newsgroups: comp.os.linux.alpha Hi Matthew, Perhaps you need a second opinion. Try this script, it adds up system and user time for processes and reports more accurately than ps: #!/bin/sh # 'sec', written by Tony Hammitt, (C) 2000, GPL 2.0 or higher, www.gnu.org # Alphas: Tix is 1000 ticks per second # i386's: Tix is 100 ticks per second Tix=100 helpm() { echo "Usage: sec " echo " Prints out CPU time and percent for the matching processes." exit 0 } case "$1" in '--help') helpm ;; '-h') helpm ;; esac tn=`cat /proc/self/stat | awk '{print $22}'` tused() { tu=`cat /proc/$1/stat | awk '{print ($14+$15)}'` pst=`cat /proc/$1/stat | awk '{print $22}'` ptu=$(echo "scale=3; 100.0*$tu/($tn-$pst)" | bc -l) #" <- this quote is here fer nedits colorizer... printf " %g%% time used since program start\n" $ptu } seconds() { if [ -f /proc/$1/stat ]; then bob=`cat /proc/$1/stat | awk '{print $14+$15}'` bthy=$(echo "scale=3; $bob/$Tix" | bc -l) echo -n $bthy "seconds used" tused $1 fi } if [ -d /proc/$1 ]; then seconds $1 else if [ $1 = 'all' ]; then ppp=`ps ax | awk '{print $1}'` else ppp=`ps ax | awk '{print $1,$5}' | grep $1 | awk '{print $1}'` fi nl=`echo $ppp | wc -w | awk '{print $1}'` if [ $nl -eq 1 ]; then seconds $ppp else ss=0 for i in $ppp; do if [ -f /proc/$i/stat ]; then th=`cat /proc/$i/stat | awk '{print $14+$15}'` name=`cat /proc/$i/stat | awk '{print $2}'` thy=$(echo "scale=3; $th/$Tix" | bc -l) echo -n $thy "seconds used by PID" $i $name tused $i ss=$(( $th + $ss )) fi done thy=$(echo "scale=3; $ss/$Tix" | bc -l) if [ $1 = 'all' ]; then printf "\n%s total seconds used in all running processes\n" $thy else printf "\n%s total seconds used in all %s's\n" $thy $1 fi fi fi exit 0 ====== Mathew Lee wrote: > > I was curious if anyone has seen this type of problem, or if it's > nothing to worry about... > > when I preform a ps aux on one of my digital 500au machines (running > linux or course) (kernel 2.2.16) > > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME > COMMAND > > userx 4182 71.7 3.2 40960 4096 ? > RN Jul26 1808:51 ./simulation copper1 > usery 4329 49.9 16.2 22360 20496 ? > RN Jul27 633:16 ./simulation copper2 > > The problem here is the third column (% CPU)....now if my Engineering > degree serves me correctly....that's greater than 100%...(actually 121.6 > %)...how can this be...or is this expected... > I am using binaries that were compiled using the Compaq C compiler. Any > suggestions are greatly appreciated.... > > Thanks, > > Matt Lee > Undergraduate Research Assistant > Mechanical and Aerospace Engineering > Oklahoma State University