Script for checking memory usage and automated email notification
Description:
Last updated: November, 2009
download: checkMemUsage(shell script), checkDetailMemUsage(shell script)
These two script are written to monitor memory usage of a (Linux)OS. You can set a threshold in the (checkMemUsage) script, and if memory consumption crosses this threshold, the second script will use the 'top' command in batch mode to generate a report of which processes are responsible for that. After that the report is send to a (or multiple) email address(es). Make sure you can send emails from your server using the 'mail' command.
Put the checkMemUsage script in the crontab. E.g. every 5 minutes. This script is especially useful if you are using a VPS with memory restrictions. Not all VPS systems do a hard cut off on your memory consumption but do monitor it and send you a warning. This allows you to see which process might be responsible for 'memory peaks'.