script for cpu utilization for each user

Can someone suggest me the script to calculate cpu utilization for each user
in solaris say for a period of 24 Hrs or last 12 Hrs
I am using solaris 10.

Thanks in Advance

clear
vmstat|awk '{print $3}'|tail -1 > avm
svmon -G|grep memory|awk '{print $2}' > svmon
svmon -G|grep pg|awk '{print $3}' > pgsize
svmon -G|grep pg|awk '{print $4}' > pginuse
paste avm svmon pgsize pginuse > stats.txt
rm avm svmon pgsize pginuse
avm=`vmstat|awk '{print $3}'|tail -1`
svmon=`svmon -G|grep memory|awk '{print $2}'`
if [ $avm -le $svmon ] ; then
awk -f vmstat.awk stats.txt
else
awk -f vmstat1.awk stats.txt
fi

$ cat vmstat.awk
{
freemem = ($2 - $1)*4096
mem = freemem / 1000000000
print "Your free memory is : "mem"G"

#totalfree = $2 + ($3 - $4)
#free = totalfree / 1000000000
#print "Your total memory is :"free"G"
}
$ cat vmstat1.awk
{
totalfree = ($2 + $3 - $4 - $1)*4096
free1 = totalfree / 1000000000
print "Your total free mem is :" free1
}
$

somthing like this..but not sme as your pro.but here is the idea.

1 Like