X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=system-status;fp=system-status;h=f9b0eee9a964e715dbda918d1323e57fd1902791;hp=dd327bb0836979310df0476389df5d4971a106dc;hb=d67edcdca8795a4bca116aa532d02dda246a6f53;hpb=a9e3d60b4254cd5c6216c4b3e7f8cd5cc5107fad diff --git a/system-status b/system-status index dd327bb..f9b0eee 100755 --- a/system-status +++ b/system-status @@ -390,17 +390,20 @@ write-status() { 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 + if [[ -s $mprom ]]; then + if grep -qE 'mailtest_check_(unexpected|missing).*[^ ][^0]$' $mprom; then + chars+=("MTEST_SPAM") + fi + mtest_found=false + # shellcheck disable=SC2013 # these are words + 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 - done - if $mtest_found; then - chars+=("MTEST_AGE") fi if [[ ! -e $status_file || -w $status_file ]]; then