Hi guys,
i have a ksh script that gets some info on processes and puts it into a temp file:
/usr/ucb/ps -auxxx|awk '{print $3," "$4," "$2," "$1," "$11}'|grep -v 0.0|sed 1d > $TMP
It gets the following data
0.8 6.2158230724046144 9918 oracle
0.3 6.2158200964043168 15298 oracle
0.2 6.2158242644046904 5625 oracle
0.2 2.0158312081322712 17654 oracle
0.1 6.2158201444043200 15290 oracle
0.1 6.2158201364043200 15296 oracle
0.1 6.2158224884045592 16852 oracle
0.1 6.2158234244046464 16132 oracle
0.1 6.2158240724046880 28809 oracle
0.1 6.2158201444043200 15292 oracle
0.1 6.2158197764042832 17330 oracle
0.1 6.2158203764043512 17342 oracle
0.1 6.2158238164046720 7273 oracle
0.1 6.2158195364042576 17336 oracle
0.1 6.2158228324045632 17006 oracle
0.1 6.2158230644046328 5610 oracle
0.1 6.2158197924042872 17209 oracle
0.1 6.2158205844043728 16499 oracle
0.1 2.0158294401314312 17648 oracle
0.1 6.2158212564044408 9284 oracle
0.1 6.2158237364046520 16843 oracle
0.1 6.2158196964042760 17111 oracle
0.1 2.1158335361326672 17646 oracle
0.1 6.2158209684044176 10763 oracle
0.1 6.2158230084046232 12294 oracle
0.1 2.0158294401318936 17650 oracle
0.1 2.0158293761314280 17652 oracle
0.1 6.2158209444044152 15352 oracle
0.1 6.2158221524045120 16940 oracle
0.1 6.2158197924042824 17364 oracle
0.1 6.2158228564046016 16417 oracle
0.1 6.2158211124044288 22806 oracle
0.1 6.2158228484045920 3866 oracle
0.1 0.12219214296 11547 root 3628800
0.1 6.2158238564046736 11902 oracle
0.1 6.2158198484042896 17285 oracle
0.1 6.2158224164045592 17346 oracle
0.1 6.2158197924042888 17360 oracle
0.1 6.2158195684042608 17386 oracle
0.1 6.2158196884042752 17390 oracle
Im only really intersted in the first two columns and need the total of both columns.
TotCPU=`cat $TMP | awk '{print $1}' | nawk '{x+=$NF}END{print int x}'`
#extract the total memory usage of all the processes
TotMem=`cat $TMP | awk '{print $2}' | nawk '{x+=$NF}END{print int x}'`
#exptract total cpu usage of all currently running processes
echo "total ps=$TotP,tot running ps=$RunP,total memory being used=$TotMem total cpu=$TotCPU" #debug
The echo produces:
total ps=1537,tot running ps=32,total memory being used=6167.813 total cpu=04.1
As well as some other lines but the one above is most important. Now the cpu one works apart from the annoyin leading 0 but the memory one produces a very wierd result. Any ideas?