From 9fbf25a7086dbd9e6d26624d249eab47a44e064c Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Wed, 8 Jun 2005 22:25:28 +0000 Subject: [PATCH] More of the same. git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@430 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd/ConfigServer.pm | 12 +----------- plugins/stats | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/Qpsmtpd/ConfigServer.pm b/lib/Qpsmtpd/ConfigServer.pm index 7a92d64..2200cb0 100644 --- a/lib/Qpsmtpd/ConfigServer.pm +++ b/lib/Qpsmtpd/ConfigServer.pm @@ -157,17 +157,7 @@ sub cmd_status { if (defined &Qpsmtpd::Plugin::stats::register) { # Stats plugin is loaded - my $uptime = Qpsmtpd::Plugin::stats->uptime; - my $recvd = Qpsmtpd::Plugin::stats->mails_received; - my $reject = Qpsmtpd::Plugin::stats->mails_rejected; - my $soft = Qpsmtpd::Plugin::stats->mails_tempfailed; - my $rate = Qpsmtpd::Plugin::stats->mails_per_sec; - $output .= sprintf(" Uptime: %0.2f sec\n". - " Mails Received: % 10d\n". - " 5xx: % 10d\n". - " 4xx: % 10d\n". - "Mails per second: %0.2f\n", - $uptime, $recvd, $reject, $soft, $rate); + $output .= Qpsmtpd::Plugin::stats->get_stats; } my $descriptors = Danga::Socket->DescriptorMap; diff --git a/plugins/stats b/plugins/stats index 1a2e1b5..92e0f4e 100644 --- a/plugins/stats +++ b/plugins/stats @@ -15,6 +15,20 @@ sub register { $self->register_hook('queue', 'increment_mails'); } +sub get_stats { + my $uptime = Qpsmtpd::Plugin::stats->uptime; + my $recvd = Qpsmtpd::Plugin::stats->mails_received; + my $reject = Qpsmtpd::Plugin::stats->mails_rejected; + my $soft = Qpsmtpd::Plugin::stats->mails_tempfailed; + my $rate = Qpsmtpd::Plugin::stats->mails_per_sec; + return sprintf(" Uptime: %0.2f sec\n". + " Mails Received: % 10d\n". + " 5xx: % 10d\n". + " 4xx: % 10d\n". + "Mails per second: %0.2f\n", + $uptime, $recvd, $reject, $soft, $rate); +} + sub increment_deny { my ($self, $tran, $plugin, $level) = @_;