If you're running a reasonably secure environment for qmail you might find that qmail script doesn't work. This is mostly likely that apache doesn't have permissions to access qmail stats. You can overcome this by having a cron output the stats to a file:
Code: Select all
*/5 * * * * root /var/qmail/bin/qmail-qstat > /tmp/qmail-qstat
Code: Select all
#!/usr/bin/perl
#
# qmailq.pl
#
# Author : Jeremy Garcia <jeremy@linuxquestions.org>
# Modified : Ollie Maitland
# Date : 07/07/04, 25/04/06
# Version : 0.3
# Description : Script to output the number of messages in a qmail queue.
# Output is <messages in queue> <messages in queue but not yet
# preprocessed>
# Thanks to Nick, who alerted me to the fact that the script
# needed an update
# to be compatible with the latest version of cacti.
# Full path to qmail-stat. If you are using Linux you will need to write
# a SUID perl wrapper as suid sh scripts are no good in Linux.
#@queue = `/var/qmail/bin/qmail-qstat`;
open (QMAIL, '</tmp/qmail-qstat');
my @queue = <QMAIL>;
close QMAIL;
@jqueue = split " ",$queue[0];
@pro = split " ",$queue[1];
print join(':','messages',$jqueue[3])," ",join(':','unprocessed',$pro[7]);
Code: Select all
find: queue/mess/*: Permission denied
find: queue/todo: Permission denied
messages in queue: -1
messages in queue but not yet preprocessed: -1