From: Adriano Prado <prado@gmx.net>
Subject: A useful tool (CPU usage)
Date: 2000/09/21 [thread overview]
Message-ID: <8qd7sq$t2r$1@nnrp1.deja.com> (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.
next reply other threads:[~2000-09-21 4:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-21 4:00 Adriano Prado [this message]
2000-09-22 4:00 ` A useful tool (CPU usage) Pedro M. Matias
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