monitoring qmail

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
gregm
Posts: 38
Joined: Mon Oct 21, 2002 4:19 pm

monitoring qmail

Post by gregm »

has anyone done any scripts for getting stats stats from qmail?

there's one for mrtg, http://inter7.com/qmailmrtg7/ .. looks like it could be adapted easily, anyone ever try this, or have a better solution?
alexus
Posts: 40
Joined: Fri Feb 04, 2005 8:38 pm
Location: Brooklyn, New York
Contact:

Post by alexus »

it'd be nice if something like was available for cacti
[url]http://alexus.org/[/url] - [url]http://alexus.biz/[/url] - [url]http://alexus.fm/[/url] - [url]http://lexus.gs/[/url]
gregm
Posts: 38
Joined: Mon Oct 21, 2002 4:19 pm

Post by gregm »

Funny you reply to this 3-year old message now, as I've just been updating my stats programs.

Here's one for reading how many messages are sitting in the queue:

Code: Select all

#!/bin/bash

# outputs messages in local queue  and messages in remote queue
if [ "$1" == "local" ];
then
        /var/qmail/bin/qmHandle -s | sed -r  '$!N;s/.*: ([0-9]+)\n.*: ([0-9]+)/\1/g'
else
        /var/qmail/bin/qmHandle -s | sed -r  '$!N;s/.*: ([0-9]+)\n.*: ([0-9]+)/\2/g'
fi
call it with the parameter "local" if you want local, or "remote" if you want remote.

Here's one to get the last 5 minutes of your mail log:

Code: Select all

#!/bin/bash

cat /var/log/maillog | awk '
BEGIN {
        pass = 0;
        search = "^" strftime("%b %d %H:%M", systime() - 5 * 60);
        }
{
        if ($0 ~ search) pass = 1;
        if (pass) print $0
}
END { pass = 0}'
I run it in cron:

*/5 * * * * /usr/bin/get5minmaillog > /var/stats/mail5min

Then in cacti, one of my data input method is:

grep -c "<text>" /var/stats/mail5min

and I have a couple of data sources setup .. one that puts <text> as "new msg" is for messages received. One that checks for "identified spam" is how many messages spam assassin identifies.

(I should mention I don't have this graphing properly yet. I actually got frustrated with it and gave up. This script gives sane results, but it never posts to my graphs properly. usually as 0, ocasionally spiking to 10k or something. when I run it manually, it's always hovering between 100 and 300.)
alexus
Posts: 40
Joined: Fri Feb 04, 2005 8:38 pm
Location: Brooklyn, New York
Contact:

Post by alexus »

i thought to monitor it in more details then just this..
[url]http://alexus.org/[/url] - [url]http://alexus.biz/[/url] - [url]http://alexus.fm/[/url] - [url]http://lexus.gs/[/url]
gttommy
Posts: 25
Joined: Thu Oct 06, 2005 6:52 pm
Contact:

Post by gttommy »

gregm:

Thanks for posting your ideas. I found that the awk command does not work for me...so I modified it so that it now does (not an elegant solution hehe):

BEGIN {
pass = 0;
search1 = "^" strftime("%Y-%m-%d %H:%M", systime() - 1 * 60);
search2 = "^" strftime("%Y-%m-%d %H:%M", systime() - 2 * 60);
search3 = "^" strftime("%Y-%m-%d %H:%M", systime() - 3 * 60);
search4 = "^" strftime("%Y-%m-%d %H:%M", systime() - 4 * 60);
search5 = "^" strftime("%Y-%m-%d %H:%M", systime() - 5 * 60);
}
{
if ($0 ~ search5) pass = 1;
else if ($0 ~ search4) pass = 1;
else if ($0 ~ search3) pass = 1;
else if ($0 ~ search2) pass = 1;
else if ($0 ~ search1) pass = 1;

if (pass) print $0
}
END { pass = 0}'

And as for the improper output for cacti, make sure that the all commands being called (e.g. /bin/cat, /bin/grep, etc) include the full path...since crontab will probably not work if the php is calling a unix command without specifying full path it.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests