Created
July 23, 2013 22:56
-
-
Save javier-lopez/6066888 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
[ -s /tmp/logstash_alert ] || exit 1 | |
_mail() | |
{ #send mail, return 0 on success, 1 otherwise | |
#requires: libio-socket-ssl-perl, libnet-ssleay-perl and sendemail | |
case $1 in | |
gmail) | |
shift | |
sendemail -f "$1" -t "$2" -u "$3" -m "$4" -s smtp.gmail.com:587 -o tls=yes -xu "$5" -xp "$6" | |
;; | |
*) | |
sendemail -f "$1" -t "$2" -u "$3" -m "$4" -s "$5" -xu "$6" -xp "$7" > /dev/null 2>&1 | |
;; | |
esac | |
[ $? -eq 0 ] && return 0 || return 1 | |
} | |
_mail gmail "noreply@domain.com" "recipient@domain.com" "alarm :$(date +%d-%m-%Y)" "$(cat /tmp/logstash_alert)" "username" "password" | |
status=$? | |
[ $status != 0 ] && exit $status || { cat /dev/null > /tmp/logstash_alert; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment