Postfix Mail Queue Monitor

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Postfix Mail Queue Monitor

Scott Miller-3
In case anyone is interested, I've attached a working Postfix Mail Queue
Monitor for nagios - It's working for me as is, but if anyone has any
suggested modifications I'd be glad to look at them.

Thanks,
Scott Miller

check_postfix_mailq.txt (3K) Download Attachment
commands.cfg.txt (825 bytes) Download Attachment
localhost.cfg.txt (382 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Postfix Mail Queue Monitor

Barney Desmond
2009/9/30 Scott Miller <[hidden email]>:
> In case anyone is interested, I've attached a working Postfix Mail Queue
> Monitor for nagios - It's working for me as is, but if anyone has any
> suggested modifications I'd be glad to look at them.

We do something like this where I work, a mailqueue-size check for
nagios via NRPE. There was some discussion a little while ago finding
the queue size; the long and the short is that invoking postqueue is
bad (it's painfully slow).

If you're interested, dig up the thread in your favourite archives and
have a read, the subject is/was "Recommended way to (quickly) get
total mail queue size?", around 2009-07-08.

I'm in the process of improving our own systems, which will move to
using Victor's suggested perl script. In some ad-hoc testing, I reckon
it's easily 1-2 orders of magnitude faster than postqueue when there's
a fair amount of mail queued up.

P.S. Apologies if I'm wrong about the script using postqueue, but I
didn't read every single line, just had a skim to appease my
suspicions.
Reply | Threaded
Open this post in threaded view
|

Re: Postfix Mail Queue Monitor

Len Conrad
In reply to this post by Scott Miller-3
>2009/9/30 Scott Miller <[hidden email]>:
>> In case anyone is interested, I've attached a working Postfix Mail Queue
>> Monitor for nagios - It's working for me as is, but if anyone has any
>> suggested modifications I'd be glad to look at them.
>
>We do something like this where I work, a mailqueue-size check for
>nagios via NRPE. There was some discussion a little while ago finding
>the queue size; the long and the short is that invoking postqueue is
>bad (it's painfully slow).
>
>If you're interested, dig up the thread in your favourite archives and
>have a read, the subject is/was "Recommended way to (quickly) get
>total mail queue size?", around 2009-07-08.
>
>I'm in the process of improving our own systems, which will move to
>using Victor's suggested perl script. In some ad-hoc testing, I reckon
>it's easily 1-2 orders of magnitude faster than postqueue when there's
>a fair amount of mail queued up.
>
>P.S. Apologies if I'm wrong about the script using postqueue, but I
>didn't read every single line, just had a skim to appease my
>suspicions.

here's mine, very fast with "find":

#!/bin/sh

for Q in incoming active deferred hold ; do

SIZE="`find /mail/spool/postfix/$Q -maxdepth 5 -type f | wc -l | tr -d ' ' `"

dd  if=/dev/zero bs=1 count=$SIZE of=/var/db/postfix/q_size_$Q

done

exit 0


then I have monit monitor the filesizes of those 4 files.

Len

Reply | Threaded
Open this post in threaded view
|

Re: Postfix Mail Queue Monitor

Victor Duchovni
On Tue, Sep 29, 2009 at 10:55:32PM +0200, Len Conrad wrote:

> here's mine, very fast with "find":
>
> #!/bin/sh
>
> for Q in incoming active deferred hold
> do
> SIZE=`find /mail/spool/postfix/$Q -maxdepth 5 -type f | wc -l | tr -d ' '`
> dd if=/dev/zero bs=1 count=$SIZE of=/var/db/postfix/q_size_$Q
> done
> exit 0

The find(1) is less efficient than it should be, because you don't need
to lstat(2) the files as with "-type f". All the sub-directories of
the queues have single-letter names, and all the queue-files have
multi-letter names. With a POSIX shell, avoid the `cmd` construct.

    n=$$( $(find /var/spool/postfix/$Q ! -name "?" ! | wc -l) - 1 )

--
        Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:[hidden email]?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.