Mainly add external monitoring of mail server
[distro-setup] / system-status
old mode 100755 (executable)
new mode 100644 (file)
index 12621cc..747e2a6
@@ -31,6 +31,10 @@ write-status() {
   if [[ -e ${glob[0]} ]]; then
     chars+=("STALE!")
   fi
+  if [[ $(find /var/mail -type f \! -empty -print -quit) ]]; then
+    var_mail_msg="message in /var/mail"
+  fi
+  lo -1 var_mail $var_mail_msg
   glob=(/m/md/bounces/new/*)
   if [[ -e ${glob[0]} ]]; then
     chars+=("BOUNCE!")
@@ -50,17 +54,24 @@ write-status() {
     qlen=$(sudo /usr/sbin/exiqgrep -o 60 -c -b | awk '{print $1}')
   fi
   if ((qlen)); then
+    qmsg="queue length $qlen"
     chars+=("q $qlen")
   fi
+  case $HOSTNAME in
+    # No point in emailing about the mailq on a host where we don't
+    # check email.
+    $MAIL_HOST|l2)
+      lo -1 qlen $qmsg
+      ;;
+  esac
 
   begin=false
-  cd /b/ds
-  if ! make -q ~/.local/distro-begin || [[ $(<~/.local/distro-begin) != 0 ]]; then
+  if ! make -C /b/ds -q ~/.local/distro-begin || [[ $(<~/.local/distro-begin) != 0 ]]; then
     begin=true
   fi
 
   end=false
-  if ! make -q ~/.local/distro-end || [[ $(<~/.local/distro-end) != 0 ]]; then
+  if ! make -C /b/ds -q ~/.local/distro-end || [[ $(<~/.local/distro-end) != 0 ]]; then
     end=true
   fi
 
@@ -94,9 +105,8 @@ write-status() {
         done
 
         # just because i forget a lot, -mmin -NUM means files modified <= NUM minutes ago
-        if (( $(date -d "$(git log --diff-filter=ACR --format=%aD -1)" +%s) > fsec )) || \
-             [[ $(find ${all_dirs[@]} -mmin $fmin -type f -print -quit 2>/dev/null) ]]; then
-          v conflink newer git or newer filesystem files
+        if   [[ $(find ${all_dirs[@]} -mmin $fmin -type f -print -quit 2>/dev/null) ]]; then
+          v conflink newer filesystem files
           chars+=("CONFLINK!")
           break
         fi
@@ -107,6 +117,12 @@ write-status() {
             # some hosts i dont push all of /p/c
             continue
           fi
+          if (( $(date -d "$(git log --diff-filter=ACR --format=%aD -1)" +%s) > fsec )); then
+            v conflink: newer files checked in to git
+            chars+=("CONFLINK!")
+            break
+          fi
+
           untracked=$(git ls-files -o --exclude-standard)
           if [[ $untracked && $(find $untracked -mmin $fminplus -type f -print -quit) ]]; then
             v conflink: untracked in $d
@@ -114,6 +130,7 @@ write-status() {
             break
           fi
         done
+        cd /
 
       fi
       if [[ ! -e $f || $(<$f) != 0 ]]; then
@@ -164,7 +181,7 @@ write-status() {
     # Profiled it using time and also adding to the top of the file:
     # set -x
     # PS4='+ $(date "+%2N") '
-    snaps=($(ls -1avdr /mnt/root/btrbk/$vol.20*|head -n1))
+    snaps=($(ls -1avdr /mnt/root/btrbk/$vol.20*|head -n1 || [[ $? == 141 ]] ))
     now=$(date +%s)
     maxtime=0
     for s in ${snaps[@]}; do