Diff for /badi/public_scripts/canardien/canardien between versions 1.2 and 1.3

version 1.2, 2010/08/08 17:18:37 version 1.3, 2013/06/26 00:13:44
Line 1 Line 1
 #!/bin/bash  #!/bin/bash
   
 # canardien 0.0.2  # canardien 0.0.3
 # (c) 2005 under GPL by Adrian Zaugg  # (c) 2005 under GPL by Adrian Zaugg
   
 # canardiens pings ente.limmat.ch to determine wether she is gone diving.  # canardiens pings ente.limmat.ch to determine wether she is gone diving.
Line 16  HOST="ente.limmat.ch" Line 16  HOST="ente.limmat.ch"
 # eMail Alerts  # eMail Alerts
 # Send alert email messages to the following address(es). Leave empty  # Send alert email messages to the following address(es). Leave empty
 # for no alert. For multiple destinations use a comma separated list.  # for no alert. For multiple destinations use a comma separated list.
 ALERT_TO=""  ALERT_TO="root"
   
 # Subject of alert email  # 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  # Text of Message (But in 'single quotes' to protect variables. They should get
 # expanded at the time the message is sent!)  # 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  # path to fping
 PING=`which fping`  PING=`which fping`
Line 57  function checkconnection { Line 57  function checkconnection {
                 echo "Error: fping external program not in path. Exitting."                  echo "Error: fping external program not in path. Exitting."
                 exit 1                  exit 1
         fi          fi
      
    PING_ANSWER="$($PING "$HOST")"     PING_ANSWER="$($PING "$HOST")"
    PING_ERRNUM=$?     PING_ERRNUM=$?
    if [ $PING_ERRNUM -gt 2 ]; then     if [ $PING_ERRNUM -gt 2 ]; then
                 echo "Error $PING_ERRNUM in fping $(head -1 "$PING_ANSWER") . Exitting."                  echo "Error $PING_ERRNUM in fping $(head -1 "$PING_ANSWER") . Exitting."
                 exit 1                  exit 1
    fi     fi
      
    if [ `echo "$PING_ANSWER" | grep -c "$ALIVE_ANSWER"` -gt 0 ]; then     if [ `echo "$PING_ANSWER" | grep -c "$ALIVE_ANSWER"` -gt 0 ]; then
       UP=true        UP=true
    fi     fi
Line 84  function checkconnection { Line 84  function checkconnection {
 function rememberstate {  function rememberstate {
    # Put a simple time stamp in a tmp file, when host gets down     # Put a simple time stamp in a tmp file, when host gets down
    if [ -z "$UP" ]; then     if [ -z "$UP" ]; then
         if [ ! -e "$TMPDIR/.canardien-$PINGHOST-$HOST" ]; then                   if [ ! -e "$TMPDIR/.canardien-$PINGHOST-$HOST" ]; then 
                 # set time stamp                  # set time stamp
                 echo -ne "$TIME_STAMP" > "$TMPDIR/.canardien-$PINGHOST-$HOST"                  echo -ne "$TIME_STAMP" > "$TMPDIR/.canardien-$PINGHOST-$HOST"
                 # send alert                  # send alert
Line 98  function rememberstate { Line 98  function rememberstate {
          if [ -n "$DEBUG" ]; then           if [ -n "$DEBUG" ]; then
             shout "$HOST is up again."              shout "$HOST is up again."
          fi           fi
           # send alert                    # send alert
           ALERT_SUBJECT="$HOST antwortet wieder!"            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."'            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            sendalert
          # delete tmp file           # delete tmp file
Line 141  checkconnection Line 141  checkconnection
 rememberstate  rememberstate
 exit 0  exit 0
   
   

Removed from v.1.2  
changed lines
  Added in v.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>