Skip to content

Instantly share code, notes, and snippets.

@coffeemakr
Created October 1, 2014 08:39
Show Gist options
  • Save coffeemakr/df6b21bc1fbbbbb36e1f to your computer and use it in GitHub Desktop.
Save coffeemakr/df6b21bc1fbbbbb36e1f to your computer and use it in GitHub Desktop.
Memory Mon
#!/bin/sh
meminfo=`free -m | grep 'Mem:'`
used=`echo $meminfo | cut -d" " -f3`
total=`echo $meminfo | cut -d" " -f2`
cached=`echo $meminfo | cut -d" " -f7`
really_used=`expr $used - $cached`
percent=$(bc -l <<EOF
$really_used / $total * 100
EOF
)
printf "<<M%.2f%%|C%s>>" $percent $cached
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment