Last active
October 13, 2015 09:37
-
-
Save codeb2cc/4175586 to your computer and use it in GitHub Desktop.
Memeory usage monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MEM=$(cat /proc/meminfo | ack 'MemFree: +(\d+)' --output "\$1" | bc) | |
CAC=$(cat /proc/meminfo | ack '^Cached: +(\d+)' --output "\$1" | bc) | |
FREE=$(echo "$MEM + $CAC" | bc) | |
THRESHOLD=1048576 | |
echo "Free Memory: $MEM kb" | |
echo "Cached: $CAC kb" | |
echo "Threshold: $THRESHOLD kb" | |
echo "Avaiable: $FREE kb" | |
if [ $FREE -lt $THRESHOLD ]; then | |
echo "WARNNING!" | |
else | |
echo "OK" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment