How to find the load on CPU ?

Hi ALL,
I have to develop a script which checks for the load on CPU on regular intervals. I created a simple script which uses 'uptime' command to find out the avg load in the last 5 min. I then used grep and put the value of the avg load in a variable OUT.

It was working fine till now. Now I have to build one more condition wherein if the load is above 5 then I have to find out the top processes which are consuming the resources. I tried the following

if [ "$OUT" -gt "$THRESHOLD" ]
then
top -n 1 > top$$.lst
fi

But this is not working since OUT is a character variable and if condition is expecting it to be integer.

Please help me out.

OUT=`uptime|cut -d"," -f6|cut -d"." -f1`
THRESHOLD="5"
if [ "$OUT" -gt "$THRESHOLD" ]
then
echo "Below are the TOP 5 processes"
ps -eo pcpu,pid,user,args | sort -r|grep -v "%CPU"|head -5
else
echo "CPU under control"
fi

Thanks for your reply.

But the problem is not solved. Here is the script ....

#!/bin/ksh

OUT1=`date | awk '{print $1" "$2" "$3" "$4" "}'`
TIME=`date +%H:%M`
OUT2=`uptime | awk '{print $8}' | sed 's/\,//g'`
OUT=`uptime|cut -d"," -f6|cut -d"." -f1`
echo $OUT2
THRESHOLD="5"
if [ "$OUT" -gt "$THRESHOLD" ]
then
top -n 1 > top$TIME
fi

and when I run it following it errors out with following :

-bash: [: : integer expression expected

Any Clues ??

if ur using the bash shell change ksh to bash...

I did the change ... but it didnt help ...

have u been try this?
if [ "$OUT" > "$THRESHOLD" ]