Skip to content

Instantly share code, notes, and snippets.

@windows98SE
Last active August 29, 2015 14:00
Show Gist options
  • Save windows98SE/11033805 to your computer and use it in GitHub Desktop.
Save windows98SE/11033805 to your computer and use it in GitHub Desktop.
cpu info mac osx
myCPU=`top -l 1 | awk '/CPU usage/ {print $3}' | sed s/%//`
myCPU=`echo "tmp=$myCPU; tmp /= 1; tmp" | bc`
typeset -i b=9
echo "CPU Usage \c"
while [ $b -lt $myCPU ]
do
echo "|\c"
b=`expr $b + 10`
done
while [ $b -lt 99 ]
do
echo "\033[2;30m|\033[0m\c"
b=`expr $b + 10`
done
echo " $myCPU%\c"
echo "\r"
unset myCPU
unset b
myUsedMem=`top -l 1 | awk '/PhysMem/ {print $2}' | sed s/M// `
myFreeMem=`top -l 1 | awk '/PhysMem/ {print $6}' | sed s/M// `
myActiveMem=`top -l 1 | awk '/PhysMem/ {print $4}' | sed s/M// | sed s/\(// `
myTotalMem=` expr $myUsedMem + $myFreeMem`
myUsedPer=`echo $myActiveMem $myTotalMem | awk '{print int($1/$2*100)}'`
typeset -i c=9
echo "Memory Usage \c"
while [ $c -lt $myUsedPer ]
do
echo "|\c"
c=`expr $c + 10`
done
while [ $c -lt 99 ]
do
echo "\033[2;30m|\033[0m\c"
c=`expr $c + 10`
done
echo " $myUsedPer%\c"
echo "\r"
unset myUsedMem
unset myFreeMem
unset myTotalMem
unset myUsedPer
unset c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment