qmail-qstats modified

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

Post Reply
olliemaitland
Posts: 9
Joined: Tue May 17, 2005 2:46 pm

qmail-qstats modified

Post by olliemaitland »

Hello...

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
and then use a modified sript to read the data:

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]);
Pretty obvious but some people might be having problems...incidentally for those people searching errors, this is what you might get when trying to use apache directly on the qmail-qstat binary:

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
Hope this helps :)
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests