Last active
June 15, 2016 22:14
-
-
Save stampycode/bc1a8cb83c06fd5002bb4fa6292086b9 to your computer and use it in GitHub Desktop.
utility script for recording the memory in use on a server and emailing and clearing the log intermittently
This file contains 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/bash | |
EMAIL=<insert your email here> | |
cd /home/ec2-user | |
if [[ $1 == "send" ]] ; then | |
sleep 5 | |
cat memlog | /usr/bin/sendmail -F"MemLog <$EMAIL>" $EMAIL | |
echo > memlog | |
echo `/bin/date +"%Y-%m-%d %H:%I:%S"` `/usr/bin/free -m |grep total` >> memlog | |
exit | |
fi | |
echo `/bin/date +"%Y-%m-%d %H:%I:%S"` `/usr/bin/free -m |grep Mem` >> memlog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment