Depends on bug and check file bug

Issue #146 resolved
Former user created an issue

I think I've found two bugs that have arisen since the release of monit-5.9+. I have a check for the local mailq's on our systems. Here is my monit conf file check:

check program mailq with path /usr/local/monit/conf/conf.d/scripts/mailq.sh
   with timeout 30 seconds
   if status != 0 then alert

check file mailq-sub with path /var/run/mailq.size
   if changed checksum
      then alert
   depends on mailq

and the associated bash file that gets executed:

#!/bin/bash
#
# Helper script for monit to check the mail queue's. Monit will watch
# /var/run/mailq-sub.size.
#

MAX_SIZE=${1:-10}

CHECK_FILE="/var/run/mailq.size"
LOCK_FILE="${CHECK_FILE}.lock"

[ -f $CHECK_FILE ] || echo 0 > $CHECK_FILE

CUR_SIZE=`mailq -Ac | tail -n 1 | awk '{ print($3); }'`

if [ $CUR_SIZE -gt $MAX_SIZE ]; then
     if [ ! -f $LOCK_FILE ]; then
            echo $CUR_SIZE > $CHECK_FILE
            echo > $LOCK_FILE
     fi
else
     rm -f $LOCK_FILE
fi

exit 0

When running this conf with monit-5.8.1, monit will start fine even though the mailq.size file doesn't actually exist, and it will execute the bash script above and the file is created.

In monit-5.9+, monit will fail to even start with the following error:

checksum: file /var/run/mailq.size is not regular file
/usr/local/monit/conf/conf.d/mailq.conf:6: Cannot compute a checksum for file /var/run/mailq.size '/var/run/mailq.size'
/usr/local/monit/conf/conf.d/mailq.conf:6: Invalid checksum [0000000000000000000000000000000000000000] for file /var/run/mailq.size '/var/run/mailq.size'

In monit-5.8.1, it would continue on it's merry way and create the file once the 'mailq' check was run. It seems that the depends on statement is broken in 5.9+ as well, as it should ignore the 'mailq-sub' check until the 'mailq' check is satisfied. The mailq.size file is never created on 5.9+.

Comments (4)

  1. Former user Account Deleted reporter

    I should also note, that changing the 'mailq-sub' check to something like this fails as well:

    check file mailq-sub with path /var/run/mailq.size
       if does not exist then exec "/bin/touch /var/run/mailq.size"
       if changed checksum
          then alert
       depends on mailq
    
  2. Tildeslash repo owner

    Hello Aaron, thanks for report.

    It's not related to dependency - the problem was caused by the checksum test, which tried to verify the hash length vs. the selected hash type - when the file was not present, dummy 40-bytes value was set, but the default hash is MD5, which uses 32 bytes.

    The problem is fixed in the development version.

  3. Log in to comment