fi
}
+
+pl=/var/log/exim4/paniclog
main() {
- if [[ ! -s /var/log/exim4/paniclog ]]; then
+ if [[ ! -s $pl ]]; then
return 0
fi
# seems to randomly be caused by
# Starting exim4-base housekeeping, exim4-base.service
regex="^[^ ]* 00:00:0.* Failed writing transport results to pipe: Broken pipe$"
- grep "$regex" /var/log/exim4/paniclog >> /var/log/exim4/paniclog-archive ||:
- sed -i "/$regex/d" /var/log/exim4/paniclog
+ grep "$regex" $pl >> $pl-archive ||:
+ sed -i "/$regex/d" $pl
+
+ ## begin broken pipe ##
+ regex="Failed writing transport results to pipe: Broken pipe$"
+ now_s=$(date +%s)
+ newlines=false
+ count=0
+ while read -r day time _; do
+ log_s=$(date -d "$day $time" +%s)
+ count=$((count+1))
+ if (( now_s - 300 > log_s )); then
+ newlines=true
+ fi
+ done < <(grep "$regex" $pl ||:)
+ if (( count )); then
+ # i see these in groups of 3 for the same message around once a day
+ # randomly. I'm guessing they are related to running 2 instances of
+ # exim which share the same spool. So, if we have some, but not in
+ # the last 5 minutes, and less than 20, it should be fine to clear
+ # them.
+ if (( count > 20 )); then
+ cat $pl
+ elif ! $newlines; then
+ grep "$regex" $pl >>$pl-archive
+ sed -i "/$regex/d" $pl
+ fi
+ fi
+ ## end broken pipe ##
while read -r service regex; do
found=false
wipe=false
break
fi
- done < <(awk "/$regex/ "'{print $1,$2}' /var/log/exim4/paniclog)
+ done < <(awk "/$regex/ "'{print $1,$2}' $pl)
if $found && $wipe; then
d "wiping $regex"
- if [[ ! -w /var/log/exim4/paniclog-archive ]]; then
- touch /var/log/exim4/paniclog-archive
- chgrp adm /var/log/exim4/paniclog-archive
- chmod 664 /var/log/exim4/paniclog-archive
+ if [[ ! -w $pl-archive ]]; then
+ touch $pl-archive
+ chgrp adm $pl-archive
+ chmod 664 $pl-archive
fi
- grep -E "$regex" /var/log/exim4/paniclog >> /var/log/exim4/paniclog-archive ||:
- sed -ri "/$regex/d" /var/log/exim4/paniclog
+ grep -E "$regex" $pl >> $pl-archive ||:
+ sed -ri "/$regex/d" $pl
fi
done <<'EOF'
clamav-daemon malware acl condition