Check mailq outputing garbage


yoda# ./check_mailq -w 10 -c 20 -M qmail -v
wc: not found
find: not found
wc: 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

this is what I get when I run the mailqueue:

yoda# /var/qmail/bin/qmail-qstat
messages in queue: 4
messages in queue but not yet preprocessed: 0

I dug throught the scripts several times, I dont see what it is calling, anyone have any ideas?


As the same user that you ran as, when you got “not found” type this:
which wc
If you get not found, then your user’s path doesn’t include the location of the wc command. Likewise for the rest, so check the user’s $PATH.


Ah HAH! I got it :slight_smile:

on line 43 of check_mailq you need to set the path, to wc and find.


default is $ENV{‘PATH’}=’’;


#adding mail
define command{
command_name check_mail
command_line $USER1$/check_mailq -w 10 -c 20 -M qmail

define service{
use generic-service ; Name of service template
host_name res-yoda-01
service_description Mail Queue
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 960
notification_period 24x7
check_command check_mail

runs fine via command line:
yoda# /usr/local/libexec/nagios/check_mailq -w 10 -c 20 -M qmail
WARNING: mailq is 10 (threshold w = 10)|unsent=10;10;20;0

yet in the web interface it gets cannot match output.
[1118067719] SERVICE ALERT: res-yoda-01;Mail Queue;UNKNOWN;HARD;4;Couldn’t match /var/qmail/bin/qmail-qstat output


anyone have any idea why it works command line but not in web tool?


Yes, try this.
Execute the command by su - nagios first.
Most likely, the permissions are not correct, and nagios doesn’t have permission to execute that command, but when you try it by hand in the console, you might be doing it as root.


/usr/local/libexec/nagios/check_mailq -w 10 -c 20 -M qmail
find: queue/mess/*: Permission denied
find: queue/todo: Permission denied

when I su -l nagios

drwxr-x— 25 qmailq qmail 512 May 17 07:41 mess
drwx------ 2 qmailq qmail 512 Jun 20 15:48 pid
drwx------ 25 qmails qmail 512 May 17 07:41 remote
drwxr-x— 2 qmailq qmail 512 Jun 20 15:42 todo

so how do I set the permissions without hosing up qmail?


I’d add nagios user to the /etc/group file in the group qmail.