done
fi
}
-pr() {
- if $doprom && [[ -e /var/lib/prometheus/node-exporter ]]; then
- cat >>/var/lib/prometheus/node-exporter/mailtest-check.prom.$$
- fi
-}
#### begin arg processing ####
main() {
+ local -a p_unexpected_spamd_results p_missing_dnswl p_last_usec
case $HOSTNAME in
bk)
folders=(/m/md/{expertpathologyreview.com,amnimal.ninja}/testignore)
;;
esac
done
- pr <<EOF
+ mapfile -O ${#p_missing_dnswl[@]} -t p_missing_dnswl <<EOF
mailtest_check_missing_dnswl{folder="$folder",from="$from"} $missing_dnswl
+EOF
+ mapfile -O ${#p_unexpected_spamd_results[@]} -t p_unexpected_spamd_results <<EOF
mailtest_check_unexpected_spamd_results{folder="$folder",from="$from"} $unexpected
EOF
fi # if spamdpid
e $((age_sec / 60)):$(( age_sec % 60 )) ago. to:$to from:$from $latest
# usec = unix seconds
- pr <<EOF
+ mapfile -O ${#p_last_usec[@]} -t p_last_usec <<EOF
mailtest_check_last_usec{folder="$folder",from="$from"} $last_sec
EOF
done # end for from in ${froms[@]}
done # end for folder in ${folders[@]}
dir=/var/lib/prometheus/node-exporter
- if [[ -e $dir ]]; then
- mv $dir/mailtest-check.prom.$$ $dir/mailtest-check.prom
+ path=$dir/mailtest-check.prom.$$
+ if $doprom && [[ -e $dir ]]; then
+ for l in "${p_unexpected_spamd_results[@]}"; do
+ printf "%s\n" "$l" >>$path
+ done
+ for l in "${p_missing_dnswl[@]}"; do
+ printf "%s\n" "$l" >>$path
+ done
+ for l in "${p_last_usec[@]}"; do
+ printf "%s\n" "$l" >>$path
+ done
+ mv $path $dir/mailtest-check.prom
# note: node_textfile_mtime_seconds will tell us when this last happened. useful for debugging.
fi
}