Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* A useful tool (CPU usage)
@ 2000-09-21  4:00 Adriano Prado
  2000-09-22  4:00 ` Pedro M. Matias
  0 siblings, 1 reply; 2+ messages in thread
From: Adriano Prado @ 2000-09-21  4:00 UTC (permalink / raw)


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

-----------<cut here>-------------
#!/bin/ksh
#----------------------------------
# Shows the percent CPU usage
# (show only process with CPU
# usage > 0.0%)
#----------------------------------
# Adriano Prado de Carvalho
# <prado@gmx.net>
# 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
-----------<cut here>-------------

--
_______________________
Adriano Prado
prado@gmx.net


Sent via Deja.com http://www.deja.com/
Before you buy.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: A useful tool (CPU usage)
  2000-09-21  4:00 A useful tool (CPU usage) Adriano Prado
@ 2000-09-22  4:00 ` Pedro M. Matias
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro M. Matias @ 2000-09-22  4:00 UTC (permalink / raw)


top also does that, although you have to be superuser to really be able to
see the details.

Your script is interesting and I tried it out on our Alphas with no
problem. The only
minor complaint is that is also reports on its own processes doing the
report.

Pedro Matias


Adriano Prado wrote:

> 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
>
> ...




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-09-22  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-09-21  4:00 A useful tool (CPU usage) Adriano Prado
2000-09-22  4:00 ` Pedro M. Matias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox