Skip to content

Instantly share code, notes, and snippets.

@kjoconnor
Created September 15, 2011 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjoconnor/1219733 to your computer and use it in GitHub Desktop.
Save kjoconnor/1219733 to your computer and use it in GitHub Desktop.
Stupidly simple memory monitoring script
#!/bin/bash
# Tested on Ubuntu 8.04 32 bit
# When the memory limit drops below $memory_limit megabytes, bash will ring a bell
# and echo the current memory usage.
# Set the free memory limit (in megabytes)
memory_limit=150
# Check interval (in seconds)
interval=30
while true; do
free_memory=`free -m | tail -2 | head -1 | awk '{print $4;}'`
if (( $free_memory < $memory_limit )); then
echo "Warning: memory is $free_memory!"
echo $'\a'
fi
sleep $interval
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment