From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,9c7eb0890d815790,start X-Google-Attributes: gidfa528,public From: Adriano Prado Subject: A useful tool (CPU usage) Date: 2000/09/21 Message-ID: <8qd7sq$t2r$1@nnrp1.deja.com>#1/1 X-Deja-AN: 672471944 X-Http-Proxy: 1.0 spo-pg-intra:8080 (Squid/2.3.STABLE1), 1.0 x65.deja.com:80 (Squid/1.1.22) for client 172.17.200.95, 200.212.96.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Sep 21 15:02:03 2000 GMT X-MyDeja-Info: XMYDJUIDapcarvalho Newsgroups: comp.unix.tru64 X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 98) I've developed this simple but useful tool to see how's the CPU occupancy. It shows the processes using the CPU, its occupancy and the sum of all processes... I runned it on Digital Unix 4.0d ------------------------ #!/bin/ksh #---------------------------------- # Shows the percent CPU usage # (show only process with CPU # usage > 0.0%) #---------------------------------- # Adriano Prado de Carvalho # # 31/08/2000 #---------------------------------- l="" ps -efo pcpu -o cmd | grep "\." | grep -v "^ 0\.0 " | cut -b 1-80 | sort -n | while read x do echo "$x" y=`echo $x|cut -f 1 -d " "` if `echo $y | grep -E "^[0-9]+\.[0-9]$" > /dev/null` then l="$l $y" fi done l="$l end" psrinfo -n #number of processors echo "Percent CPU usage from `hostname`" flag=0 for x in $l do if [ "$x" = "end" ] then echo "p\nq" else if [ $flag -eq 0 ] then echo "$x" else echo "$x +" fi fi flag=1 done | dc ------------------------ -- _______________________ Adriano Prado prado@gmx.net Sent via Deja.com http://www.deja.com/ Before you buy.