Log-Saftpresse
view release on metacpan or search on metacpan
lib/Log/Saftpresse/CountersOutput/Html.pm view on Meta::CPAN
] );
return;
}
sub print_smtpd_stats {
my ( $self, $cnt ) = @_;
my $connections = $cnt->get_value_or_zero('total');
my $hosts_domains = int(keys %{$cnt->get_node('per_domain')});
my $avg_conn_time = $connections > 0 ?
($cnt->get_value_or_zero('busy', 'total')
/ $connections ) + .5 : 0;
my $total_conn_time = $cnt->get_value_or_zero('busy', 'total');
print $self->headline(1, 'Smtpd Statistics');
print $self->key_value_table( "Connections", [
[ 'Connections', $connections ],
[ 'Hosts/domains', $hosts_domains ],
[ 'Avg. connect time', $avg_conn_time ],
[ 'total connect time', $total_conn_time, 'interval' ],
] );
return;
lib/Log/Saftpresse/CountersOutput/Html.pm view on Meta::CPAN
};
foreach my $table ( 'day', 'hour', 'domain' ) {
my ( $title, $key, $sort ) = @{$params->{ $table }};
print $self->headline(1, "$title SMTPD Connection Summary");
print $self->statistics_from_hashes(
legend => $table,
sort => $sort,
rows => [
[ 'connections', $smtpd_stats->get_node($key) ],
[ 'time conn.', $smtpd_stats->get_node('busy', $key) ],
[ 'avg./conn.', $self->hash_calc_avg( 2,
$smtpd_stats->get_node('busy', $key),
$smtpd_stats->get_node($key),
), ],
[ 'max. time', $smtpd_stats->get_node('busy', 'max_'.$key ), ],
],
);
}
return;
}
sub print_domain_summaries {
my ( $self, $cnt ) = @_;
my $top_cnt = $self->{'top_domains_cnt'};
$top_cnt = defined $top_cnt && $top_cnt >= 0 ?
lib/Log/Saftpresse/CountersOutput/Html.pm view on Meta::CPAN
foreach my $table ( 'sent', 'recieved' ) {
print $self->headline(1, "Host/Domain Summary: Message Delivery (top $top_cnt $table)");
print $self->statistics_from_hashes(
legend => 'host/domain',
sort => [ 'sent cnt', 'decimal', $top_cnt ],
rows => [
[ 'sent cnt', $delivered->get_node($table, 'by_domain') ],
[ 'bytes', $delivered->get_node($table, 'size', 'by_domain') ],
$table eq 'sent' ? (
# TODO
#[ 'defers', $delivered->get_node('busy', 'per_day') ],
[ 'avg delay', $self->hash_calc_avg( 2,
$delivered->get_node($table, 'delay', 'by_domain'),
$delivered->get_node($table, 'by_domain'),
), ],
[ 'max. delay', $delivered->get_node($table, 'max_delay', 'by_domain'), ],
) : (),
],
);
}
lib/Log/Saftpresse/CountersOutput/Pflogsumm.pm view on Meta::CPAN
my $pf_cnt = $cnt->{'Postfix'};
foreach my $table ( 'sent', 'recieved' ) {
print_subsect_title("Host/Domain Summary: Message Delivery (top $top_cnt $table)");
$self->print_table_from_hashes( 'host/domain',
[ 'sent cnt', 'decimal', $top_cnt ], 25, 10,
[ 'sent cnt', $pf_cnt->get_node($table, 'by_domain') ],
[ 'bytes', $pf_cnt->get_node($table, 'size', 'by_domain') ],
$table eq 'sent' ? (
# TODO
#[ 'defers', $delivered->get_node('busy', 'per_day') ],
[ 'avg delay', $self->hash_calc_avg( 2,
$pf_cnt->get_node('sent', $table, 'delay', 'by_domain'),
$pf_cnt->get_node('sent', $table, 'by_domain'),
), ],
[ 'max. delay', $pf_cnt->get_node('sent', $table, 'max_delay', 'by_domain'), ],
) : (),
);
}
return;
lib/Log/Saftpresse/CountersOutput/Pflogsumm.pm view on Meta::CPAN
'day' => [ 'Per-Day', 'per_day', 'string', 15 ],
'hour' => [ 'Per-Hour', 'per_hr', 'decimal', 15 ],
'domain' => [ 'Per-Hour', 'per_domain', [ 'connections', 'decimal', 20 ], 25 ],
};
foreach my $table ( 'day', 'hour', 'domain' ) {
my ( $title, $key, $sort, $len ) = @{$params->{ $table }};
print_subsect_title("$title SMTPD Connection Summary");
$self->print_table_from_hashes( $table, $sort, $len, 10,
[ 'connections', $cnt->get_node('conn', $key) ],
[ 'time conn.', $cnt->get_node('conn', 'busy', $key) ],
[ 'avg./conn.', $self->hash_calc_avg( 2,
$cnt->get_node('conn', 'busy', $key),
$cnt->get_node('conn', $key),
), ],
[ 'max. time', $cnt->get_node('conn', 'busy', 'max_'.$key ), ],
);
}
return;
}
sub print_traffic_summaries {
my ( $self, $cnt ) = @_;
my $pf_cnt = $cnt->{'Postfix'};
my $params = {
'day' => [ 'Per-Day', 'per_day', 'string' ],
lib/Log/Saftpresse/CountersOutput/Pflogsumm.pm view on Meta::CPAN
sub print_smtpd_stats {
my ( $self, $cnt ) = @_;
my $smtpdConnCnt = $cnt->get_value_or_zero('conn', 'total');
print "\nsmtpd\n\n";
printf " %6d%s connections\n",
adj_int_units($smtpdConnCnt);
printf " %6d%s hosts/domains\n",
adj_int_units(int(keys %{$cnt->get_node('conn', 'per_domain')}));
printf " %6d avg. connect time (seconds)\n",
$smtpdConnCnt > 0 ?
($cnt->get_value_or_zero('conn', 'busy', 'total')
/ $smtpdConnCnt ) + .5
: 0;
{
my ($sec, $min, $hr) = get_smh($cnt->get_value_or_zero('conn', 'busy', 'total'));
printf " %2d:%02d:%02d total connect time\n",
$hr, $min, $sec;
}
return;
}
sub print_problems_reports {
my ( $self, $cnt ) = @_;
if($self->deferral_detail != 0) {
lib/Log/Saftpresse/Plugin/Postfix.pm view on Meta::CPAN
* reject_reason
* connection_time
* client
=head1 Counters
The plugin generates the following counters:
<host>.conn.total
<host>.conn.per_domain.<domain>
<host>.conn.busy.total
<host>.conn.busy.per_domain.<domain>
<host>.incoming.total
<host>.reject.total.reject
<host>.bounced.total
<host>.recieved.by_sender.<sender>
<host>.recieved.by_domain.<domain>
<host>.recieved.total
<host>.recieved.size.by_sender.<sender>
<host>.recieved.size.by_domain.<domain>
<host>.recieved.size.total
<host>.tls_msg.smtpd.cipher.<tls_cipher>
lib/Log/Saftpresse/Plugin/Postfix/Smtpd.pm view on Meta::CPAN
if( ! defined $conn_time ) { return; }
my $elapsed = $time - $conn_time;
my $sec = $elapsed->seconds;
$stash->{'connection_time'} = $sec;
$stash->{'client'} = $host;
if( $self->saftsumm_mode ) {
$self->incr_host_one( $stash, 'conn', 'per_hr', $time->hour);
$self->incr_host_one( $stash, 'conn', 'per_day', $time->ymd);
$self->incr_host( $stash, 'conn', 'busy', 'per_hr', $time->hour, $sec);
$self->incr_host( $stash, 'conn', 'busy', 'per_day', $time->ymd, $sec);
$self->incr_host_max( $stash, 'conn', 'busy', 'max_per_hr', $time->hour, $sec);
$self->incr_host_max( $stash, 'conn', 'busy', 'max_per_day', $time->ymd, $sec);
$self->incr_host_max( $stash, 'conn', 'busy', 'max_per_domain', $host, $sec);
}
$self->incr_host_one( $stash, 'conn', 'per_domain', $host);
$self->incr_host( $stash, 'conn', 'busy', 'per_domain', $host, $sec);
$self->incr_host_one( $stash, 'conn', 'total');
$self->incr_host( $stash, 'conn', 'busy', 'total', $sec);
$self->clear_tracking_id('pid', $stash, $notes);
}
return;
}
1;
__END__
( run in 0.402 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )