--- badi/public_scripts/canardien/canardien 2010/08/08 17:18:37 1.2 +++ badi/public_scripts/canardien/canardien 2013/06/26 00:13:44 1.3 @@ -1,6 +1,6 @@ #!/bin/bash -# canardien 0.0.2 +# canardien 0.0.3 # (c) 2005 under GPL by Adrian Zaugg # canardiens pings ente.limmat.ch to determine wether she is gone diving. @@ -16,14 +16,14 @@ HOST="ente.limmat.ch" # eMail Alerts # Send alert email messages to the following address(es). Leave empty # for no alert. For multiple destinations use a comma separated list. -ALERT_TO="" +ALERT_TO="root" # Subject of alert email -ALERT_SUBJECT="Achtung: $HOST antwortet nicht mehr!" +ALERT_SUBJECT="Attention: no answer from $HOST anymore!" # Text of Message (But in 'single quotes' to protect variables. They should get # expanded at the time the message is sent!) -ALERT_TEXT='"\n[$TIME_STAMP]\n\nALERT!!\n\n\t$HOST is down!\n\nYou should probably do something, please.\nKind regards, $PINGHOST."' +ALERT_TEXT='"\n[$TIME_STAMP]\n\nALERT!!\n\n\t$HOST is down!\n\nYou should probably do something, please.\n\nKind regards, $PINGHOST."' # path to fping PING=`which fping` @@ -57,14 +57,14 @@ function checkconnection { echo "Error: fping external program not in path. Exitting." exit 1 fi - + PING_ANSWER="$($PING "$HOST")" PING_ERRNUM=$? if [ $PING_ERRNUM -gt 2 ]; then echo "Error $PING_ERRNUM in fping $(head -1 "$PING_ANSWER") . Exitting." exit 1 fi - + if [ `echo "$PING_ANSWER" | grep -c "$ALIVE_ANSWER"` -gt 0 ]; then UP=true fi @@ -84,7 +84,7 @@ function checkconnection { function rememberstate { # Put a simple time stamp in a tmp file, when host gets down if [ -z "$UP" ]; then - if [ ! -e "$TMPDIR/.canardien-$PINGHOST-$HOST" ]; then + if [ ! -e "$TMPDIR/.canardien-$PINGHOST-$HOST" ]; then # set time stamp echo -ne "$TIME_STAMP" > "$TMPDIR/.canardien-$PINGHOST-$HOST" # send alert @@ -98,8 +98,8 @@ function rememberstate { if [ -n "$DEBUG" ]; then shout "$HOST is up again." fi - # send alert - ALERT_SUBJECT="$HOST antwortet wieder!" + # send alert + ALERT_SUBJECT="The host $HOST answers again!!" ALERT_TEXT='"[$(date +"%a %e.%m.%y %H:%M:%S")]\n\n\n$HOST is up again.\n--------------------------------------\n(downtime began $(cat "$TMPDIR/.canardien-$PINGHOST-$HOST"))\n\n\n Kind regards, $PINGHOST."' sendalert # delete tmp file @@ -141,3 +141,4 @@ checkconnection rememberstate exit 0 +