Dashboard > Linux > Nagios Postfix Mailq Plugin
Linux Log In   View a printable version of the current page.
Nagios Postfix Mailq Plugin
Added by Scott Kveton, last edited by Scott Kveton on Nov 18, 2004  (view change)
Labels: 
(None)

Attached you'll find a modified version of the check_mailq plugin that comes with Nagios that I have adapted to use with Postfix. This works much like the old version of and uses 'mailq' aka 'postqueue -p' to get a traditional sendmail-style mailq listing which is then parsed for values that you compare to warning and critical conditionals.

I have noticed problems with larger mailq's and this tool as calling 'postqueue -p' can be pretty resource intensive on machines that are heavily loaded. I am always open to suggestions on better ways to implement this tool.

You will need to edit the 'use lib "/usr/local/nagios/plugins" ;' line at the top of the file to get it to work in your environment. This line is looking for the directory that the utils.pm file is located in.

Hi Scott,

on the page given in the subject you offer the check_postfix_mailq
Nagios tool (thanks, by the way ).

"I have noticed problems with larger mailq's and this tool as calling
'postqueue -p' can be pretty resource intensive on machines that are
heavily loaded. I am always open to suggestions on better ways to
implement this tool."

True. Wouldn't be one way to look into the spool directories directly,
bypassing postqueue at all, like

ls -1 /var/spool/postfix/deferred/?/* 2>/dev/null | wc -l

(of course for all spool files individually...)? If so, I am looking
forward to test your new Nagios plugin

Cheers,

Stephan A. Rickauer

Posted by Scott Kveton at Feb 24, 2005 08:06 | Permalink

The above would be a much better way to do this plugin for postfix. The problem with the current implmentation is that i uses 'postqueue' which is rather resource intensive when all you want is to know how many messages are in the queue; you don't care about any of the details.

Scott

Posted by Scott Kveton at Feb 24, 2005 08:07 | Permalink

The following is the patch to do what is mentioned in the above comments: 

67c67
< my $result = `/usr/sbin/postqueue -p`;
---
> #my $result = `/usr/sbin/postqueue -p`;
69,73c69,78
< if ( $result =~ /-- (\d+) Kbytes in (\d+) Request[s]*\./ ) {
<         if ( $2 > $critical ) {
<                 $state = 'CRITICAL';
<         }
<       elsif ( $2 > $warning ) {
---
> # Do it more lightweight
> my $result = `ls -1 /var/spool/postfix/deferred/?/* 2>/dev/null | wc -l`;
>
> #if ( $result =~ /-- (\d+) Kbytes in (\d+) Request[s]*\./ ) {
>
> if ( $result =~ /^(\d+)$/ ) {
>       if ( $1 > $critical ) {
>               $state = 'CRITICAL';
>       }
>       elsif ( $1 > $warning ) {
80c85,86
<       $answer = "Postfix mailq has $2 messages queued for a total of
$1 Kbytes.";
---
>       #$answer = "Postfix mailq has $2 messages queued for a total of
$1 Kbytes.";
>       $answer = "Postfix mailq has $1 messages queued.";
Posted by Scott Kveton at Jun 26, 2006 16:48 | Permalink
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.7 Build:#524 Jul 28, 2006) - Bug/feature request - Contact Administrators