Skip to content

Instantly share code, notes, and snippets.

@Red5d
Last active August 29, 2015 14:11
Show Gist options
  • Save Red5d/189b08942fef5dcedfbc to your computer and use it in GitHub Desktop.
Save Red5d/189b08942fef5dcedfbc to your computer and use it in GitHub Desktop.
function mempercent {
total=$(free -m | sed -n '2p' | awk '{print $2}')
used=$(free -m | sed -n '3p' | awk '{print $4}')
echo $(echo $(echo 'scale=2;'$used'/'$total'' | bc)*100 | bc | cut -d'.' -f1)"% memory usage (${used}M Used / ${total}M Total)"
}
function systemload {
loadAverage=$(uptime | cut -d',' -f4 | grep -o "[0-9]*\.[0-9]*$")
processors=$(cat /proc/cpuinfo | grep processor | tail -n1 | awk '{ print $3 }')
let processors=$processors+1
echo "$loadAverage ($processors.00 max)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment