this is a script made for devs who cant use ps or top command for some reasons like i did, so i thought i'd share here.
its originally made by Paul Colby(credits to him).
this script doesnt work on my shell, so i modified it to be very simple(for newbies like me;))
,and to be compatible with any bash shells.
i've also added ram usage to view.. ram usage:p
anyways...have fun coding!
press teh thanx button if i have helped you to make your project get going again:D
its originally made by Paul Colby(credits to him).
this script doesnt work on my shell, so i modified it to be very simple(for newbies like me;))
,and to be compatible with any bash shells.
i've also added ram usage to view.. ram usage:p
anyways...have fun coding!
Code:
busybox renice -n19 -p$$
busybox ionice -c3 -p$$
prev_total=0
prev_idle=0
while true; do
cpu=`cat /proc/stat | head -n1 | sed 's/cpu //'`
user=`echo $cpu | awk '{print $1}'`
system=`echo $cpu | awk '{print $2}'`
nice=`echo $cpu | awk '{print $3}'`
idle=`echo $cpu | awk '{print $4}'`
wait=`echo $cpu | awk '{print $5}'`
irq=`echo $cpu | awk '{print $6}'`
srq=`echo $cpu | awk '{print $7}'`
zero=`echo $cpu | awk '{print $8}'`
total=$(($user+$system+$nice+$idle+$wait+$irq+$srq+$zero))
diff_idle=$(($idle-$prev_idle))
diff_total=$(($total-$prev_total))
usage=$(($((1000*$(($diff_total-$diff_idle))/$diff_total+5))/10))
FREEMEM=`free | awk '{ print $4 }' | sed -n 2p`
CACHESIZE=`cat /proc/meminfo | grep Cached | awk '{print $2}' | sed -n 1p`
TOTALMEM=`free | awk '{ print $2 }' | sed -n 2p`
MEMINUSE=$(($TOTALMEM-$CACHESIZE-$FREEMEM))
usemb=$(($MEMINUSE/1024))
totalmb=$(($TOTALMEM/1024))
clear
echo "CPU usage: $usage%"
echo "RAM usage: $usemb/$totalmb MB"
prev_total=$total
prev_idle=$idle
sleep 1
done