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?
monitoring qmail
Moderators: Developers, Moderators
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:
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:
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.)
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
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}'
*/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.)
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.
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.
Who is online
Users browsing this forum: No registered users and 1 guest