minor fix
[distro-setup] / mailtest-check
index 7454086099322db19eec59bee04471d555fc297d..363401780546c8849ded6acedf7242cd0adfbaec 100755 (executable)
@@ -57,6 +57,8 @@ fi
 #Nov  8 08:16:05.439 [6080] warn: plugin: failed to parse plugin (from @INC): Can't locate Mail/SpamAssassin/Plugin/VBounce.pm: lib/Mail/SpamAssassin/Plugin/VBounce.pm: Permission denied at (eval 60) line 1.
 # i dont know why, i just found the solution online
 cd /m/md
+# TODO, get je to deliver the local mailbox: /m/md/INBOX
+# dovecot appears to setup, i can t be sure.
 
 case $HOSTNAME in
   bk)
@@ -94,9 +96,12 @@ pr() {
     cat >>/var/lib/prometheus/node-exporter/mailtest-check.prom.$$
   fi
 }
-pr <<EOF
+# first time we write, overwrite anything existing
+if [[ -e /var/lib/prometheus/node-exporter ]]; then
+  cat >/var/lib/prometheus/node-exporter/mailtest-check.prom.$$ <<EOF
 mailtest_check_found_spamd_pid_bool $(( ${spamdpid:-0} > 0 ))
 EOF
+fi
 e spamdpid: $spamdpid
 if [[ ! $spamdpid ]]; then
   echo $HOSTNAME mailtest spamd pid not found. systemctl status spamassassin:
@@ -210,7 +215,7 @@ for folder in ${folders[@]}; do
       fi # if $slow
     fi # if [[ $latest ]]
 
-    now=$(date +%s)
+    now=$EPOCHSECONDS
     limit=$(( now - 60 * min_limit ))
     age_sec=$(( now - last_sec ))
     e $((age_sec / 60)):$(( age_sec % 60 )) ago. to:$to from:$from $latest