check_mailq issue when checking qmail

Hi,

I’m using the check_mailq plugin to check the mail queue for our qmail server. I’ve done some pretty extensive troubleshooting and narrowed down the issue to the following line in the check_mailq file.

# open qmail-qstat if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) { if (! open (MAILQ, "$utils::PATH_TO_QMAIL_QSTAT | " ) ) { print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n"; exit $ERRORS{'UNKNOWN'}; }

This is where it receives input from the qmail-qstat script which contains the following:

[code]#!/bin/sh

WARNING: This file was auto-generated. Do not edit!

cd /var/qmail
messdirs=echo queue/mess/* | wc -w
messfiles=find queue/mess/* -print | wc -w
tododirs=echo queue/todo | wc -w
todofiles=find queue/todo -print | wc -w
echo messages in queue: expr $messfiles - $messdirs
echo messages in queue but not yet preprocessed: expr $todofiles - $tododirs[/code]

I thought it might be an issue of the cd command not working so I commented it out and put absolute paths in that script, but that didn’t change anything.

Here is the output that I receive when I try to run the check:

root:chestnut|12:11:09pm|/usr/local/libexec/nagios: ./check_mailq -w 40 -c 50 -M qmail wc: not found wc: not found find: not found wc: not found find: not found wc: not found expr: not found expr: not found Couldn't match /var/qmail/bin/qmail-qstat output

Any ideas as to what’s causing it to not be able to run the first part of the command in qmail-qstat when it’s executed from the check_mailq script?

Put the full paths to those commands in the script, is all I can suggest and check the permissions on those files also:
wc
find
expr

Ahh the full path to the commands did the trick. Here’s the updated copy of /var/qmail/bin/qmail-qstat:

[code]#!/bin/sh

WARNING: This file was auto-generated. Do not edit!

cd /var/qmail
messdirs=echo queue/mess/* | /usr/bin/wc -w
messfiles=/usr/bin/find queue/mess/* -print | /usr/bin/wc -w
tododirs=echo queue/todo | /usr/bin/wc -w
todofiles=/usr/bin/find queue/todo -print | /usr/bin/wc -w
echo messages in queue: /bin/expr $messfiles - $messdirs
echo messages in queue but not yet preprocessed: /bin/expr $todofiles - $tododirs[/code]