CUP and Memory

Hi All Unix experts,

I want to calculate CUP Utilization and Memory Utilization on solairs boxes.
Please help me to write a script for this, since i am doing this manualy for more than 30 servers daily.

My daily task is

# top
last pid: 28627; load avg: 8.50, 8.12, 8.16; up 100+18:32:56 11:46:38
2033 processes: 2022 sleeping, 1 zombie, 1 stopped, 9 on cpu
CPU states: 45.1% idle, 26.2% user, 27.6% kernel, 1.2% iowait, 0.0% swap
Memory: 32G phys mem, 875M free mem, 16G swap, 16G free swap

CPU Utilization = (100 - ideal value)%

and for memory is

Momory = (Physical memory - Free Momory) / Physical Memory

Please friends i would like to know how we can make it script for this..

I will rally very greatful if u help me on this......!

Thanks in advance

Could any one help me on this

CUP or CPU ?
Momory or Memory ?
Solairs or Solaris ?

Please check your message ... :confused:

you are very well know what i am coming to say..! then y can't help me..?

I'm guessing that he's trying to point out that you are in breach of a couple of rules of the forum (http://www.unix.com/unix-dummies-questions-answers/2971-simple-rules-unix-com-forums.html\) - in particular 4

The overall cpu information in top is hard to capture properly as it's generated only while top is running interactively.
You can get the memory info out though as follows:

#!/bin/sh
line=`top | grep 'Memory: '`
phys=`echo $line | awk '{ print $2 }' | sed 's/G/ \* 1048576/' | sed 's/M/ \* 1024/' | bc`
free=`echo $line | awk '{ print $4 }' | sed 's/G/ \* 1048576/' | sed 's/M/ \* 1024/' | bc`
echo "scale=3
($phys - $free) / $phys * 100" | bc