Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrors
resmon
Commits
5931052f
Commit
5931052f
authored
11 years ago
by
Sergey Joseph Ivanov
Browse files
Options
Downloads
Patches
Plain Diff
postfix queue monitoring module
parent
e5814103
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Core/Postfix.pm
+91
-0
91 additions, 0 deletions
lib/Core/Postfix.pm
with
91 additions
and
0 deletions
lib/Core/Postfix.pm
0 → 100644
+
91
−
0
View file @
5931052f
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
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment