if [ "`tty`" = "not a tty" ]; then
LOGFILE="$LOGDIR/$LOGGROUP-$today.log"
+ FAILLOG="$LOGDIR/$LOGGROUP-fail-$today.log"
+ REPORT="$LOGDIR/$LOGGROUP-report-$today.log"
else
LOGFILE=/dev/stdout
+ FAILLOG=/dev/stderr
+ REPORT=/dev/stdout
fi
for host in $HOSTS; do
end_time=$(date +%s)
report="$(date +%s):$host:$(($end_time-$start_time)):$result"
- echo $report >>$LOGDIR/$LOGGROUP-report-$today.log
- [ $result != 0 ] && echo "$report" >>$LOGDIR/$LOGGROUP-fail-$today.log
+ echo $report >>"$REPORT"
+ [ $result != 0 ] && echo "$report" >>"$FAILLOG"
done
-# TODO: send fail log email report
-# TODO: delete logs older than 45 days
+if [ -s "$FAILLOG" ]; then
+ cat "$FAILLOG"
+ exit 1
+fi
+
+# TODO: delete logs older than N days