Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@evalphobia
Created July 17, 2014 03:35
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 evalphobia/717d870ac206ef48b20d to your computer and use it in GitHub Desktop.
Save evalphobia/717d870ac206ef48b20d to your computer and use it in GitHub Desktop.
Send mail for server stats by SES
#!/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