From: Tony Hammitt <thammitt@kc.rr.com>
Subject: Re: ps aux (oddity)
Date: 2000/07/28 [thread overview]
Message-ID: <39820FB3.1D48F02E@kc.rr.com> (raw)
In-Reply-To: 3981B9DA.26EB98BE@okstate.edu
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 <process ID|command|all>"
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
next prev parent reply other threads:[~2000-07-28 4:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-28 4:00 ps aux (oddity) Mathew Lee
2000-07-28 4:00 ` Tony Hammitt [this message]
2000-07-30 4:00 ` Mathew Lee
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox