Skip to content

Instantly share code, notes, and snippets.

@EvanLovely
Forked from SamRothCA/memoryusage.sh
Last active August 29, 2015 14:11
Show Gist options
  • Save EvanLovely/b27926a9c796830d2115 to your computer and use it in GitHub Desktop.
Save EvanLovely/b27926a9c796830d2115 to your computer and use it in GitHub Desktop.
ps xmo rss=,pmem=,comm= | while read rss pmem comm; ((n++<5)); do
size="$[rss/1024]";
short=$[4-${#size}];
size="(${size}M)";
i=0;
while ((i++ < short)); do size=" $size"; done;
pmem="${pmem%%.*}"
if (($pmem >= 20)); then color=$'\e[31m';
elif (($pmem >= 10)); then color=$'\e[33m';
else color=$'\e[32m ';
fi;
echo "$color$pmem% $size $(basename "$comm")"$'\e[0m'"";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment