mostly improvements
[distro-setup] / system-status
index 6b25454468af35da3960ea2ae8ec5756047347ad..dd327bb0836979310df0476389df5d4971a106dc 100755 (executable)
@@ -13,7 +13,7 @@ if [[ $EUID != 1000 ]]; then
   exit 1
 fi
 
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
 status_file=/dev/shm/iank-status
 
 shopt -s nullglob
@@ -389,6 +389,20 @@ write-status() {
     # leave it up to epanic-clean to send email notification
   fi
 
+  mprom=/var/lib/prometheus/node-exporter/mailtest-check.prom
+  if grep -qE 'mailtest_check_(unexpected|missing).*[^ ][^0]$' $mprom; then
+    chars+=("MTEST_SPAM")
+  fi
+  mtest_found=false
+  for t in $(grep -E ^mailtest_check_last_usec $mprom | awk '{print $NF}'); do
+    if (( t + 60 * 20 < EPOCHSECONDS )); then
+      mtest_found=true
+    fi
+  done
+  if $mtest_found; then
+    chars+=("MTEST_AGE")
+  fi
+
   if [[ ! -e $status_file || -w $status_file ]]; then
     if [[ -e /a/bin/bash_unpublished/source-state ]]; then
       cat /a/bin/bash_unpublished/source-state >$status_file
@@ -454,9 +468,14 @@ main-loop() {
 
     if $power; then
       if (( loop_count  % 10 == 0 )); then
-        bat=$(cat /sys/class/power_supply/BAT0/capacity)
+        if [[ -r /sys/class/power_supply/BAT0/capacity ]]; then
+          bat=$(cat /sys/class/power_supply/BAT0/capacity)
+        else
+          bat=100
+        fi
         case $bat in
           100|9?)
+          :
           bitcoinon &
           ;;
         esac