Created
November 30, 2012 08:40
-
-
Save jeffreyiacono/4174553 to your computer and use it in GitHub Desktop.
simple script that uses pinger + sendmail to notify you of a pinger failure for a given set of urls
This file contains hidden or 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 | |
| # usage: | |
| # | |
| # ./pinger-notifier.sh url_1 [url_2 ...] | |
| # | |
| # this use https://github.com/jeffreyiacono/pinger and assumes | |
| # it's setup via the command line (see: https://github.com/jeffreyiacono/pinger#usage) | |
| set -e | |
| for url in "$@"; do | |
| if ! msg=$(pinger $url) ; then | |
| email=$(cat <<EOS | |
| From: You <[email protected]> | |
| To: [email protected] | |
| Subject: pinger alert for $1 @ $(date "+%Y-%m-%d %H:%M:%S") | |
| Content-Type: text/html; charset=utf-8 | |
| Content-Disposition: inline; | |
| <p> | |
| <h2>$url => $msg</h2> | |
| <p>result from <code>$ pinger $1</code> @ $(date "+%Y-%m-%d %H:%M:%S")</p> | |
| </p> | |
| EOS | |
| ) | |
| echo -e "$email" | /usr/sbin/sendmail -t | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment