Skip to content
Snippets Groups Projects
Commit 5931052f authored by Sergey Joseph Ivanov's avatar Sergey Joseph Ivanov
Browse files

postfix queue monitoring module

parent e5814103
No related branches found
No related tags found
No related merge requests found
package Core::Postfix;
use strict;
use warnings;
use base 'Resmon::Module';
use Resmon::ExtComm qw(run_command cache_command);
=pod
=head1 NAME
Core::Postfix - Monitor postfix statistics using qshape
=head1 SYNOPSIS
Core::Postfix {
total : noop
gmail.com : noop
}
=head1 DESCRIPTION
This module uses the postfix command line tool qshape and its output format to check
on the queues of the postfix mailer running on the local machine.
=head1 CONFIGURATION
=over
=item 'total'
This configuration key look up with the `qshape <name>` for the names "incoming",
"active", "deferred" and "hold", and returned the total number of messages in each
of the queues.
=back
=item check_name
This configuration key look up with the `qshape <name>` for the queues "incoming",
"active", "deferred" and "hold", and returned the total number of messages in each
of the queues for the domain specified by check_name, both as recipient domain
and as a sender domain.
=back
=cut
sub handler {
my $self = shift;
my $config = $self->{config};
my $wanted_pairs;
if($self->{check_name} eq 'total') {
for my $queue ('incoming', 'active', 'deferred', 'hold') {
my $raw_lines = run_command("/usr/sbin/qshape $queue");
my @lines = split /\n/, $raw_lines;
if(!@lines) {
die "Error running `/usr/sbin/qshape\n";
}
my @Total_line = grep(/TOTAL/,@lines);
my @total_numb = split / +/, $Total_line[0];
${$wanted_pairs}{$queue} = [$total_numb[2],"i"];
}
}
else {
for my $queue ('incoming', 'active', 'deferred', 'hold') {
my $raw_lines = run_command("/usr/sbin/qshape $queue");
my @lines = split /\n/, $raw_lines;
if(!@lines) {
die "Error running `/usr/sbin/qshape\n";
}
my @Domain_line = grep(/$self->{check_name}/,@lines);
my @Domain_numb = split / +/, $Domain_line[0];
$Domain_numb[2]=0 if not $Domain_numb[2];
${$wanted_pairs}{$queue.'.rcp.'.$self->{check_name}} = [$Domain_numb[2],"i"];
$raw_lines = run_command("/usr/sbin/qshape -s $queue");
@lines = split /\n/, $raw_lines;
if(!@lines) {
die "Error running `/usr/sbin/qshape\n";
}
@Domain_line = grep(/$self->{check_name}/,@lines);
@Domain_numb = split / +/, $Domain_line[0];
$Domain_numb[2]=0 if not $Domain_numb[2];
${$wanted_pairs}{$queue.'.snd.'.$self->{check_name}} = [$Domain_numb[2],"i"];
}
}
return $wanted_pairs;
};
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment