Created
July 17, 2014 03:35
-
-
Save evalphobia/717d870ac206ef48b20d to your computer and use it in GitHub Desktop.
Send mail for server stats by SES
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 | |
FROM="$1" | |
TO="$2" | |
SUBJECT="server stats for `hostname` on `date +\"%Y-%m-%d %H:%M:%S\"`" | |
if [ "$FROM" == '' -o "$TO" == '' ]; then | |
echo 'set FROM and TO address' | |
echo 'usage: $ mail-server-status from-address@example.com to-address@example.com' | |
exit | |
fi | |
# initialize | |
OUTPUT="" | |
# show process | |
OUTPUT=$OUTPUT"\n"$(ps aux) | |
# show sysstat | |
OUTPUT=$OUTPUT"\n"$(sar -A -s `date +"%H:%M:%S" -d '2 hours ago'`) | |
echo -e "$OUTPUT" | ses-send-email.pl -s $SUBJECT -f $FROM $TO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment