Live check CPU MEM

SOURCE: http://community.ubnt.com/t5/airOS-Software-Configuration/RAM-CPU-Usage-GUI/td-p/141345

using putty,
L: ubnt
P:

# cd /var/etc/persistent
# cat check.sh

#!/bin/sh
#by Alexandre Jeronimo Correa <ajcorrea@gmail.com>
#13-06-2015
#Based on original script by Paul Colby (http://colby.id.au)
PREV_TOTAL=0
PREV_IDLE=0
while true; do
cat /proc/stat | grep ‘^cpu ‘ > /tmp/cpu
TOTAL=`awk ‘{print $2+$3+$4+$5+$6+$7+$8+$9+$10}’ /tmp/cpu` # Get the total CPU statistics.
IDLE=`awk ‘{print $5}’ /tmp/cpu` # Get the idle CPU time.
# Calculate the CPU usage since we last checked.
let “DIFF_IDLE=$IDLE-$PREV_IDLE”
let “DIFF_TOTAL=$TOTAL-$PREV_TOTAL”
let “DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10”
echo -en “\rCPU: $DIFF_USAGE% ”
# Remember the total and idle CPU times for the next check.
PREV_TOTAL=”$TOTAL”
PREV_IDLE=”$IDLE”
# check MEMFREE
MEMFREE=`awk ‘/MemFree/ {printf( “%.2f\n”, $2 / 1024 )}’ /proc/
echo -en “MEMFREE: $MEMFREE””MB”
# Wait before checking again.
sleep 1
done

# chmod 755 check.sh
# ./check.sh

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s