X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=epanic-clean;fp=epanic-clean;h=a7220c2cf03267c2c2aacdd6822c172537d2d297;hb=aa9cb10514e29340a6d6a194ee189fa4364f1f2e;hp=514162d086a8437260cfabedb094ae5c9f9698c3;hpb=e93a488af3a47f059a407dd797d48459d3f639ef;p=distro-setup diff --git a/epanic-clean b/epanic-clean index 514162d..a7220c2 100755 --- a/epanic-clean +++ b/epanic-clean @@ -25,16 +25,45 @@ d() { 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 @@ -68,16 +97,16 @@ main() { 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