Parcourir la source

Add LOGFILE option for cron.sh
Set to /dev/null to only receive errors.
Set to /dev/stdout to receive mail for each ping.
Set to a file writable by the cron runner to record pings.
(Errors will be sent in cron mail)

Jon Lundy il y a 10 ans
Parent
commit
c119e11e7f
1 fichiers modifiés avec 8 ajouts et 2 suppressions
  1. 8 2
      templates/cron.sh

+ 8 - 2
templates/cron.sh

@@ -11,11 +11,17 @@
 UUID="{{ uuid|default('00000000-0000-0000-0000-000000000000') }}"
 PEERFINDER="{{ peerfinder }}"
 NB_PINGS=5
+LOGFILE='/dev/null' # Set to /dev/null to only receive errors.
+                    # Set to /dev/stdout to receive mail for each ping.
+                    # Set to a file writable by the cron runner to record pings.
+                    #  (Errors will be sent in cron mail)
 
 # This avoids synchronisation (everybody fetching jobs and running
 # measurements simultaneously)
 RANDOM_DELAY=30
 
+[ -e $LOGFILE ] || touch $LOGFILE
+
 [ -z "$1" ] && FAMILY="ipv4" || FAMILY="ipv6"
 
 [ "$FAMILY" = "ipv4" ] && PING="ping -n -q" || PING="ping6 -n -q"
@@ -43,9 +49,9 @@ else
     echo $output | sed -e 's#.*rtt min/avg/max/mdev = \(.*\)/\(.*\)/\(.*\)/\(.*\) ms$#\1\t\2\t\3\t\4#' > /tmp/"$FAMILY"_tmp2
     read minrtt avgrtt maxrtt jitter < /tmp/"$FAMILY"_tmp2
     [ -z "$avgrtt" ] && exit
-    echo "RTT to target $id ($ip) is $avgrtt"
+    echo "RTT to target $id ($ip) is $avgrtt" >> $LOGFILE
     args="minrtt=${minrtt}&avgrtt=${avgrtt}&maxrtt=${maxrtt}&jitter=${jitter}"
 fi
 
 # Report results back to peerfinder
-curl -s -d "target=${id}&probes_sent=${sent}&probes_received=${received}&${args}" "$PEERFINDER"/result/report/"$UUID"
+curl -s -d "target=${id}&probes_sent=${sent}&probes_received=${received}&${args}" "$PEERFINDER"/result/report/"$UUID" >> $LOGFILE