aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes8
-rw-r--r--MANIFEST8
-rw-r--r--MANIFEST.SKIP63
-rw-r--r--Makefile.PL4
-rwxr-xr-xnetsnmp-sendmail-setup2
-rw-r--r--sendmail.pl211
6 files changed, 187 insertions, 109 deletions
diff --git a/Changes b/Changes
index a2a3c88..1f2388a 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,11 @@
+0.97 2023-11-15
+
+* Don't bail out if mailq or mailstats fails.
+
+0.96 2021-02-13
+
+* Change bugtracker address.
+
0.95 2016-10-04
* Add README, improve meta-data
diff --git a/MANIFEST b/MANIFEST
index 20e2baa..cb1246c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,12 +1,12 @@
Changes
+install-mib.pl
LICENSE
Makefile.PL
MANIFEST This list of files
+MANIFEST.SKIP
+netsnmp-sendmail-setup
README
-Sendmail.pm
SENDMAIL-STATS.txt
-install-mib.pl
Sendmail.mib2c
sendmail.pl
-META.yml Module YAML meta-data (added by MakeMaker)
-META.json Module JSON meta-data (added by MakeMaker)
+Sendmail.pm
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
new file mode 100644
index 0000000..58696be
--- /dev/null
+++ b/MANIFEST.SKIP
@@ -0,0 +1,63 @@
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+\bSCCS\b
+,v$
+\B\.svn\b
+\B\.git\b
+\B\.gitignore\b
+\b_darcs\b
+\B\.cvsignore$
+
+# Avoid VMS specific MakeMaker generated files
+\bDescrip.MMS$
+\bDESCRIP.MMS$
+\bdescrip.mms$
+
+# Avoid Makemaker generated and utility files.
+\bMANIFEST\.bak
+\bMakefile$
+\bblib/
+\bMakeMaker-\d
+\bpm_to_blib\.ts$
+\bpm_to_blib$
+\bblibdirs\.ts$ # 6.18 through 6.25 generated this
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build/
+\bBuild.bat$
+\bBuild.COM$
+\bBUILD.COM$
+\bbuild.com$
+
+# Avoid temp and backup files.
+~$
+\.old$
+\#$
+\b\.#
+\.bak$
+\.tmp$
+\.#
+\.rej$
+
+# Avoid OS-specific files/dirs
+# Mac OSX metadata
+\B\.DS_Store
+# Mac OSX SMB mount metadata files
+\B\._
+
+# Avoid Devel::Cover and Devel::CoverX::Covered files.
+\bcover_db\b
+\bcovered\b
+
+# Avoid MYMETA files
+^MYMETA\.
+
+^debug.sh
+^tmp
+^buildreq
+^\.emacs\.*
+
+\.tar$
+\.tar\.gz$
diff --git a/Makefile.PL b/Makefile.PL
index e496bc9..b9cef16 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -41,6 +41,10 @@ WriteMakefile(
url => 'git://git.gnu.org.ua/netsnmp-sendmail.git',
web => 'http://git.gnu.org.ua/cgit/netsnmp-sendmail.git/',
},
+ bugtracker => {
+ web => 'https://puszcza.gnu.org.ua/bugs/?group=netsnmp-sendmail',
+ mailto => 'gray+netsnmp-sendmail@gnu.org.ua'
+ }
},
provides => Module::Metadata->provides(version => '2', dir => '.')
}
diff --git a/netsnmp-sendmail-setup b/netsnmp-sendmail-setup
index 5e49ad6..53f5b21 100755
--- a/netsnmp-sendmail-setup
+++ b/netsnmp-sendmail-setup
@@ -92,7 +92,7 @@ sub restart_service {
system($cmd);
} else {
foreach $cmd (@restart_commands) {
- my @c = map { (my $s = $_) =~ s/\$service/$service/g; $s } @$cmd;
+ my @c = map { s/\$service/$service/g; $_ } @$cmd;
if (can_run($c[0])) {
printlog(L_NOTICE, "running @c");
system(@c);
diff --git a/sendmail.pl b/sendmail.pl
index e5e8df4..a1795a8 100644
--- a/sendmail.pl
+++ b/sendmail.pl
@@ -20,8 +20,8 @@ NetSNMP::Sendmail - NetSNMP plugin for Sendmail statistics
=head1 SYNOPSIS
-B<perl use NetSNMP::Sendmail qw (:config bindir /usr/bin/sm.bin);>
-
+B<perl use NetSNMP::Sendmail qw (:config bindir /usr/bin/sm.bin);>
+
=head1 DESCRIPTION
A perl plugin for B<net-snmp> that provides access to Sendmail
@@ -51,7 +51,7 @@ passed as a hash to the B<Configure> function, or passed with the
B<use> statement following the B<:config> marker. The following
options are defined:
-=over 4
+=over 4
=item B<bindir>
@@ -63,30 +63,30 @@ using B<mailq> and B<mailstats> keywords.
=item B<cf>
Absolute name of the Sendmail configuaration file. Defaults to
-F</etc/mail/sendmail.cf>.
-
+F</etc/mail/sendmail.cf>.
+
=item B<mailstats>
-Name of the B<mailstats> binary. Default is B<mailstats>.
-
+Name of the B<mailstats> binary. Default is B<mailstats>.
+
=item B<mailq>
-Name of the B<mailq> binary. Default is B<mailq>.
-
+Name of the B<mailq> binary. Default is B<mailq>.
+
=item B<mailstats_ttl>
Time in seconds during which the result of the recent invocation of
B<mailstats>(8) is cached. Default is 10.
-
+
=item B<mailq_ttl>
Time in seconds during which the result of the recent invocation of
B<mailq>(1) is cached. Default is 10.
-=back
+=back
=head2 OIDS
-
+
The MIB is defined in file SENDMAIL-STATS.txt, which is distributed along
with this module. The following OIDs are defined:
@@ -106,101 +106,101 @@ the following elements (I<N> stands for the row index):
=item B<queueName.>I<N>
Name of the queue group.
-
+
=item B<queueDirectory.>I<N>
Queue directory.
-
-=item B<queueMessages.>I<N>
-Number of messages in that queue group.
-
-=back
-
+=item B<queueMessages.>I<N>
+
+Number of messages in that queue group.
+
+=back
+
=item B<mailerTable>
This OID provides a conceptual table of mailers with the corresponding
statistics. Each row has the following elements (I<N> stands for the
row index):
-=over 4
-
+=over 4
+
=item B<mailerName.>I<N>
Name of the mailer, as set in its definition in F<sendmail.cf>.
-
+
=item B<mailerMessagesFrom.>I<N>
-Number of outgoing messages sent using this mailer.
-
+Number of outgoing messages sent using this mailer.
+
=item B<mailerKBytesFrom.>I<N>
Number of kilobytes in outgoing messages sent using this mailer.
-
+
=item B<mailerMessagesTo.>I<N>
Number of messages received using this mailer.
-
+
=item B<mailerKBytesTo.>I<N>
Number of kilobytes in messages received using this mailer.
-
+
=item B<mailerMessagesRejected.>I<N>
-Number of messages rejected by this mailer.
-
+Number of messages rejected by this mailer.
+
=item B<mailerMessagesDiscarded.>I<N>
-Number of messages discarded by this mailer.
-
+Number of messages discarded by this mailer.
+
=item B<mailerMessagesQuarantined.>I<N>
Number of messages put in quarantine by this mailer.
-
+
=back
-
+
=item B<totalMessagesFrom.0>
Total number of outgoing messages.
-
+
=item B<totalKBytesFrom.0>
Total number of outgoing kilobytes.
-
+
=item B<totalMessagesTo.0>
Total number of incoming messages.
-
+
=item B<totalKBytesTo.0>
Total number of incoming kilobytes.
-
+
=item B<totalMessagesRejected.0>
Total number of rejected messages.
-
+
=item B<totalMessagesDiscarded.0>
Total number of discarded messages.
-
+
=item B<totalMessagesQuarantined.0>
Total number of messages put in quarantine.
-
+
=item B<connectionMessagesFrom.0>
Number of messages sent over TCP connections.
-
+
=item B<connectionMessagesTo.0>
Number of messages received over TCP connections.
-
+
=item B<connectionMessagesRejected.0>
Number of messages that arrived over TCP connections and were rejected.
-=back
+=back
=head1 SEE ALSO
@@ -213,11 +213,11 @@ GPLv3+: GNU GPL version 3 or later, see
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
-
+
=head1 AUTHOR
-Sergey Poznyakoff <gray@gnu.org>.
-
+Sergey Poznyakoff <gray@gnu.org>.
+
=cut
package NetSNMP::Sendmail;
@@ -226,7 +226,7 @@ use strict;
use warnings;
use feature 'state';
use NetSNMP::agent::Support;
-use NetSNMP::agent (':all');
+use NetSNMP::agent (':all');
use NetSNMP::ASN (':all');
use Carp;
@@ -235,7 +235,7 @@ use Data::Dumper;
require Exporter;
our @ISA = qw(Exporter);
-our $VERSION = "0.95";
+our $VERSION = "0.97";
our @EXPORT_OK = qw(&Configure);
@@ -253,7 +253,7 @@ my %config = (
mailstats_ttl => \$ttl{mailstats},
mailq => \$mailq_bin,
mailstats => \$mailstats_bin,
- cf => \$sendmail_cf,
+ cf => \$sendmail_cf,
bindir => sub {
$mailq_bin = "$_[1]/$mailq_bin" if $mailq_bin !~ m#^/#;
$mailstats_bin = "$_[1]/$mailstats_bin" if $mailstats_bin !~ m#^/#;
@@ -324,7 +324,7 @@ sub readcf {
my $name = $1;
# Collect parameters. So far only P is actially used.
my %h = map { if (/([a-zA-Z])[^=]*=(.+)/) {
- if (exists($qopt{$1})) {
+ if (exists($qopt{$1})) {
$qopt{$1} => $2;
} else {
()
@@ -332,7 +332,7 @@ sub readcf {
} else {
()
}
- } split /,\s*/, $2;
+ } split /,\s*/, $2;
if (exists($h{queueDirectory})) {
my $dir = $h{queueDirectory};
delete $h{$dir};
@@ -356,25 +356,27 @@ sub queue_stats {
my $now = time();
return %tmp if $now - $timestamp{mailq} < $ttl{mailq};
$timestamp{mailq} = $now;
- %tmp = ();
}
- open(my $fd, '-|', $mailq_bin)
- or die "can't run $mailq_bin: $!";
- while (<$fd>) {
- chomp;
- if (/^(^\S+) is empty/) {
- push @{$tmp{q}}, { queueName => $qgroup{$1}{queueName} || "",
- queueDirectory => $1,
- queueMessages => 0 };
- } elsif (/^\s*(\S+) \((\d+) requests\)/) {
- push @{$tmp{q}}, { queueName => $qgroup{$1}{queueName} || "",
- queueDirectory => $1,
- queueMessages => $2 };
- } elsif (/Total requests:\s+(\d+)\s*$/) {
- $tmp{total} = $1
+ %tmp = ();
+ if (open(my $fd, '-|', $mailq_bin)) {
+ while (<$fd>) {
+ chomp;
+ if (/^(^\S+) is empty/) {
+ push @{$tmp{q}}, { queueName => $qgroup{$1}{queueName} || "",
+ queueDirectory => $1,
+ queueMessages => 0 };
+ } elsif (/^\s*(\S+) \((\d+) requests\)/) {
+ push @{$tmp{q}}, { queueName => $qgroup{$1}{queueName} || "",
+ queueDirectory => $1,
+ queueMessages => $2 };
+ } elsif (/Total requests:\s+(\d+)\s*$/) {
+ $tmp{total} = $1
+ }
}
+ close($fd);
+ } else {
+ warn "can't run $mailq_bin: $!";
}
- close($fd);
return %tmp;
}
@@ -387,45 +389,47 @@ sub mailer_stats {
$timestamp{mailstats} = $now;
%mstats = ();
- debug("calling $mailstats_bin");
- open(my $fd, '-|', "$mailstats_bin -P")
- or die "can't run $mailstats_bin: $!";
- my $line = 0;
+ debug("calling $mailstats_bin");
+ if (open(my $fd, '-|', "$mailstats_bin -P")) {
+ my $line = 0;
- while (<$fd>) {
- ++$line;
+ while (<$fd>) {
+ ++$line;
+
+ next if $line == 1;
- next if $line == 1;
-
- s/^\s+//;
+ s/^\s+//;
# msgsfr bytes_from msgsto bytes_to msgsrej msgsdis msgsqur Mailer
- my @a = split /\s+/;
- if ($a[0] eq 'T') {
- @{$mstats{totals}}{('totalMessagesFrom',
- 'totalKBytesFrom',
- 'totalMessagesTo',
- 'totalKBytesTo',
- 'totalMessagesRejected',
- 'totalMessagesDiscarded',
- 'totalMessagesQuarantined')} = @a[1..7];
- } elsif ($a[0] eq 'C') {
- @{$mstats{conn}}{('connectionMessagesFrom',
- 'connectionMessagesTo',
- 'connectionMessagesRejected')} = @a[1..3];
- } else {
- my %h;
- @h{('mailerMessagesFrom',
- 'mailerKBytesFrom',
- 'mailerMessagesTo',
- 'mailerKBytesTo',
- 'mailerMessagesRejected',
- 'mailerMessagesDiscarded',
- 'mailerMessagesQuarantined',
- 'mailerName')} = @a[1..8];
- push @{$mstats{mailer}}, \%h;
+ my @a = split /\s+/;
+ if ($a[0] eq 'T') {
+ @{$mstats{totals}}{('totalMessagesFrom',
+ 'totalKBytesFrom',
+ 'totalMessagesTo',
+ 'totalKBytesTo',
+ 'totalMessagesRejected',
+ 'totalMessagesDiscarded',
+ 'totalMessagesQuarantined')} = @a[1..7];
+ } elsif ($a[0] eq 'C') {
+ @{$mstats{conn}}{('connectionMessagesFrom',
+ 'connectionMessagesTo',
+ 'connectionMessagesRejected')} = @a[1..3];
+ } else {
+ my %h;
+ @h{('mailerMessagesFrom',
+ 'mailerKBytesFrom',
+ 'mailerMessagesTo',
+ 'mailerKBytesTo',
+ 'mailerMessagesRejected',
+ 'mailerMessagesDiscarded',
+ 'mailerMessagesQuarantined',
+ 'mailerName')} = @a[1..8];
+ push @{$mstats{mailer}}, \%h;
+ }
}
+ close($fd);
+ } else {
+ warn "can't run $mailstats_bin: $!";
}
- close($fd);
return %mstats;
}
@@ -452,7 +456,7 @@ sub check_queueTable {
sub next_queueTable {
my ($len, $oid) = @_;
-
+
my $idx = getOidElement($oid, $len);
my %qstats = queue_stats();
++$idx;
@@ -478,7 +482,7 @@ sub check_mailerTable {
sub next_mailerTable {
my ($len, $oid) = @_;
-
+
my $idx = getOidElement($oid, $len);
my %mstats = mailer_stats();
@@ -500,4 +504,3 @@ sub connection_table_get {
my %mstats = mailer_stats();
return $mstats{conn}->{$name};
}
-

Return to:

Send suggestions and report system problems to the System administrator.