Discussion:
[Nagios-users] Monitore Postfix queue
Tiago Cruz
2006-05-16 11:51:49 UTC
Permalink
Hello guys,

I've write a small script do monitore postfix queue using postqueue to count the
number of emails on my queue:

postqueue -p | tail -1 | cut -d " " -f 5

The problem: Sometimes, my queue have more than 20.000 emails, and I can't count
this number of emails in less then 1 minute :-)

So, I know that this questions is not about nagios, is about postfix, but maybe
some person here has the same problem and know another way to count the postfix
queue :-)

Thanks!
--
Tiago Cruz
Network Administrator
Linux is like an Indian tent:
no Windows, no Gates and an Apache inside.
morten
2006-05-16 13:11:04 UTC
Permalink
"munin" has a script for this called "postfix_mailqueue"
You could always get that and make a wrapper for it ...
Then maybe run it on the postfix server using net-snmps exec function so
you can query it from your nagiosserver via check_snmpp :)
Post by Tiago Cruz
Hello guys,
I've write a small script do monitore postfix queue using postqueue to count the
postqueue -p | tail -1 | cut -d " " -f 5
The problem: Sometimes, my queue have more than 20.000 emails, and I can't count
this number of emails in less then 1 minute :-)
So, I know that this questions is not about nagios, is about postfix, but maybe
some person here has the same problem and know another way to count the postfix
queue :-)
Thanks!
Matthias Eble
2006-05-16 13:20:13 UTC
Permalink
Post by Tiago Cruz
Hello guys,
I've write a small script do monitore postfix queue using postqueue to count the
postqueue -p | tail -1 | cut -d " " -f 5
The problem: Sometimes, my queue have more than 20.000 emails, and I can't count
this number of emails in less then 1 minute :-)
check_mailq in the the nagios-plugin distribution does sth similar.
check_mailq - check to see how many messages are in the smtp
queue awating transmittal.

it has support for postfix,sendmail,exim and qmail i think

hth
matthias
Tiago Cruz
2006-05-16 14:47:05 UTC
Permalink
Hello list!

Matthias,
The mailq binary don't work for me, and I don't know why :(

# /.../bin-1.4.2/libexec/check_mailq -v -w 500 -c 800 -M postfix
Couldn't match output

John,
I'll try do some like this, but is not perfect :)
ls -l /var/spool/postfix/deferred/* | grep '-' | wc -l

Morten,
Thanks guy, I'll see this "munin" package!

Very thanks to all!
--
Tiago Cruz
Network Administrator
Linux is like an Indian tent:
no Windows, no Gates and an Apache inside.
Dhawal Doshy
2006-05-16 15:21:08 UTC
Permalink
Post by Tiago Cruz
Hello list!
Matthias,
The mailq binary don't work for me, and I don't know why :(
# /.../bin-1.4.2/libexec/check_mailq -v -w 500 -c 800 -M postfix
Couldn't match output
Most likely a permission error.. try this:
# su - postfix -s /bin/sh
# /path/to/check_mailq -v -w 500 -c 800 -M postfix

Again, check_mailq uses "use lib "nagios/plugins";", you might need to
change to /directory/of/utils.pm and execute the check.

- dhawal
Post by Tiago Cruz
John,
I'll try do some like this, but is not perfect :)
ls -l /var/spool/postfix/deferred/* | grep '-' | wc -l
Morten,
Thanks guy, I'll see this "munin" package!
Very thanks to all!
Tiago Cruz
2006-05-16 16:55:12 UTC
Permalink
Post by Dhawal Doshy
# su - postfix -s /bin/sh
# /path/to/check_mailq -v -w 500 -c 800 -M postfix
Not is permission... I'm running as root (as postfix don't works too) :(
Post by Dhawal Doshy
Again, check_mailq uses "use lib "nagios/plugins";", you might need to
change to /directory/of/utils.pm and execute the check.
Yes, is everything OK... I think that my personal postfix package is a lot of
different from what plugin want, because in a "normal" postfix of debian the
scrips works :-)

Anyway, the fast way is use wc on queue directory, I'll do this... the output
says one or two emails more than real, but to 20.000 its ok ;)

Thanks!
Luc I. Suryo
2006-05-16 18:31:00 UTC
Permalink
fyi: i used a perl script that couple people created sometime ago
(Subhendu Ghosh/Carlos Canau/Benjamin Schmid) if you want too i can
email it to you...

-ls
Post by Tiago Cruz
Post by Dhawal Doshy
# su - postfix -s /bin/sh
# /path/to/check_mailq -v -w 500 -c 800 -M postfix
Not is permission... I'm running as root (as postfix don't works too) :(
Post by Dhawal Doshy
Again, check_mailq uses "use lib "nagios/plugins";", you might need to
change to /directory/of/utils.pm and execute the check.
Yes, is everything OK... I think that my personal postfix package is a lot
of different from what plugin want, because in a "normal" postfix of debian
the scrips works :-)
Anyway, the fast way is use wc on queue directory, I'll do this... the
output says one or two emails more than real, but to 20.000 its ok ;)
-
Steve Shipway
2006-05-16 19:24:15 UTC
Permalink
Post by Tiago Cruz
I've write a small script do monitore postfix queue using
postqueue -p | tail -1 | cut -d " " -f 5
The problem: Sometimes, my queue have more than 20.000
emails, and I can't count this number of emails in less then
1 minute :-)
We had this problem, too. So, I wrote a different plugin that uses Perl.
The quickest way to do this is to just count the number of files in the
postfix queue directory, although this requires the plugin to run with the
appropriate group permissions (which I achieved by using a sudo wrapper).

The postqueue (or mailq) commands take a lot longer because they parse the
messages in order to output all the extra information, which you arent
interested in.

Steve

Loading...