[svn:qpsmtpd] rev 429 - in branches/high_perf: lib/Qpsmtpd plugins
[email protected] 8 Jun 2005 22:24:00 -0000
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
Author: msergeant
Date: Wed Jun 8 15:24:00 2005
New Revision: 429
Removed:
branches/high_perf/lib/Qpsmtpd/Stats.pm
Modified:
branches/high_perf/lib/Qpsmtpd/ConfigServer.pm
branches/high_perf/plugins/stats
Log:
Move the stats code purely into the plugin so that this can be extended
easier.
Modified: branches/high_perf/lib/Qpsmtpd/ConfigServer.pm
==============================================================================
--- branches/high_perf/lib/Qpsmtpd/ConfigServer.pm (original)
+++ branches/high_perf/lib/Qpsmtpd/ConfigServer.pm Wed Jun 8 15:24:00 2005
@@ -155,13 +155,13 @@ sub cmd_status {
my $output = "Current Status as of " . gmtime() . " GMT\n\n";
- if ($INC{'Qpsmtpd/Stats.pm'}) {
+ if (defined &Qpsmtpd::Plugin::stats::register) {
# Stats plugin is loaded
- my $uptime = Qpsmtpd::Stats->uptime;
- my $recvd = Qpsmtpd::Stats->mails_received;
- my $reject = Qpsmtpd::Stats->mails_rejected;
- my $soft = Qpsmtpd::Stats->mails_tempfailed;
- my $rate = Qpsmtpd::Stats->mails_per_sec;
+ 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".
Modified: branches/high_perf/plugins/stats
==============================================================================
--- branches/high_perf/plugins/stats (original)
+++ branches/high_perf/plugins/stats Wed Jun 8 15:24:00 2005
@@ -1,6 +1,12 @@
#!/usr/bin/perl -w
use Qpsmtpd::Stats;
+use Time::HiRes qw(time);
+
+my $START_TIME = time;
+our $MAILS_RECEIVED = 0;
+our $MAILS_REJECTED = 0;
+our $MAILS_TEMPFAIL = 0;
sub register {
my ($self) = @_;
@@ -13,10 +19,10 @@ sub increment_deny {
my ($self, $tran, $plugin, $level) = @_;
if ($level == DENY or $level == DENY_DISCONNECT) {
- $Qpsmtpd::Stats::MAILS_REJECTED++;
+ $MAILS_REJECTED++;
}
elsif ($level == DENYSOFT or $level == DENYSOFT_DISCONNECT) {
- $Qpsmtpd::Stats::MAILS_TEMPFAIL++;
+ $MAILS_TEMPFAIL++;
}
return DECLINED;
@@ -25,7 +31,29 @@ sub increment_deny {
sub increment_mails {
my $self = shift;
- $Qpsmtpd::Stats::MAILS_RECEIVED++;
+ $MAILS_RECEIVED++;
return DECLINED;
}
+
+sub uptime {
+ return (time() - $START_TIME);
+}
+
+sub mails_received {
+ return $MAILS_RECEIVED;
+}
+
+sub mails_rejected {
+ return $MAILS_REJECTED;
+}
+
+sub mails_tempfailed {
+ return $MAILS_TEMPFAIL;
+}
+
+sub mails_per_sec {
+ return ($MAILS_RECEIVED / uptime());
+}
+
+