bunch of updates and fixes
[distro-setup] / system-status
index 49f734a63243aee83d33f3a641583e5b53231d8c..c6f3fe7f5144d3c3661196289cc8cfbb062059ed 100755 (executable)
@@ -24,8 +24,9 @@ write-status() {
   glob=(/m/md/bounces/new/*)
   if [[ -e ${glob[0]} ]]; then
     chars+=("BOUNCE!")
-    lo -1 bounce "message in /m/md/bounces/new"
+    bouncemsg="message in /m/md/bounces/new"
   fi
+  lo -1 bounce $bouncemsg
   glob=(/m/md/alerts/new/* /m/md/alerts/cur/*)
   if [[ -e ${glob[0]} ]]; then
     chars+=("ALERT!")
@@ -33,17 +34,36 @@ write-status() {
   if [[ -e /nocow/user/mailtest-failure ]]; then
     chars+=("MAILPING!")
   fi
+
+  ## Clean the paniclog, but only up to 4 times per day, or else we
+  ## should investigate.
+  loglog=/tmp/panicloglog-$(date --rfc-3339=date)
+  if [[ -s $loglog ]]; then
+    spamcount=$(stat -c%s $loglog)
+  else
+    spamcount=0
+  fi
+  if (( spamcount <= 4 )); then
+    if grep -q 'spam acl condition' /var/log/exim4/paniclog; then
+      printf . >>$loglog
+    fi
+    /a/bin/distro-setup/epanic-clean
+  fi
+
   if [[ -s /var/log/exim4/paniclog ]]; then
     chars+=("PANIC!")
-    tail /var/log/exim4/paniclog | lo -1 paniclog
+    tail -n 20 /var/log/exim4/paniclog | lo -1 paniclog
+  else
+    lo -1 paniclog
   fi
 
   source /a/bin/bash_unpublished/source-state
   if [[ $MAIL_HOST == "$HOSTNAME" ]]; then
     if [[ $(systemctl is-active btrbk.timer) != active ]]; then
       chars+=("BTRBK.TIMER!")
-      lo -60 btrbk.timer "btrbk.timer not enabled"
+      bbkmsg="btrbk.timer not enabled"
     fi
+    lo -60 btrbk.timer $bbkmsg
 
     ## check if last snapshot was within an hour
     vol=o
@@ -59,8 +79,9 @@ write-status() {
     done
     if (( maxtime < now - 60*60 )); then
       chars+=("OLD-SNAPSHOT!")
-      lo -1 old-snapshot "/o snapshot older than 1 hour"
+      snapshotmsg="/o snapshot older than 1 hour"
     fi
+    lo -1 old-snapshot $snapshotmsg
   fi
 
   cat /a/bin/bash_unpublished/source-state >$status_file