diff -Nur -x '*.orig' -x '*.rej' smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl mezzanine_patched_smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl --- smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl 2007-10-11 16:51:20.000000000 -0400 +++ mezzanine_patched_smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl 2007-10-11 16:51:11.000000000 -0400 @@ -75,6 +75,7 @@ # 0.6.15 - bjr - fix columns included in totals # - sort out domains when more that one email address in recipient field # 0.6.16 - cb - fix date range bug (http://bugs.contribs.org/show_bug.cgi?id=3366) +# 0.6.17 - cb - avoid numerous re-openings of config db # # TODO # ---- @@ -231,16 +232,18 @@ # store the domain of interest. Every other records are stored in a 'Other' zone my $ddb = esmith::DomainsDB->open_ro or die "Couldn't open DomainsDB : $!\n"; +my $cdb = esmith::ConfigDB->open_ro or die "Couldn't open ConfigDB : $!\n"; + foreach my $domain( $ddb->get_all_by_prop( type => "domain" ) ) { $byrcptdomain{ $domain->key }{ 'type' }='local'; } -$byrcptdomain{ esmith::ConfigDB->open_ro->get('SystemName')->value . "." - . esmith::ConfigDB->open_ro->get('DomainName')->value }{ 'type' } = 'local'; +$byrcptdomain{ $cdb->get('SystemName')->value . "." + . $cdb->get('DomainName')->value }{ 'type' } = 'local'; # is this system a MX-Backup ? -if (esmith::ConfigDB->open_ro->get('mxbackup')){ - if ( ( esmith::ConfigDB->open_ro->get('mxbackup')->prop('status') || 'disabled' ) eq 'enabled' ) { - my %MXValues = split( /,/, ( esmith::ConfigDB->open_ro->get('mxbackup')->prop('name') || '' ) ) ; +if ($cdb->get('mxbackup')){ + if ( ( $cdb->get('mxbackup')->prop('status') || 'disabled' ) eq 'enabled' ) { + my %MXValues = split( /,/, ( $cdb->get('mxbackup')->prop('name') || '' ) ) ; foreach my $data ( keys %MXValues ) { $byrcptdomain{ $data }{ 'type' } = "mxbackup-$MXValues{ $data }" ; if ( $MXValues{ $data } == 1 ) { # subdomains allowed, must take care of this @@ -256,32 +259,32 @@ # First check current configuration for logging, DNS enable and Max threshold for spamassassin # -my $LogLevel = esmith::ConfigDB->open_ro->get('qpsmtpd')->prop('LogLevel'); +my $LogLevel = $cdb->get('qpsmtpd')->prop('LogLevel'); my $HighLogLevel = ( $LogLevel > 6 ); my $RHSenabled = - ( esmith::ConfigDB->open_ro->get('qpsmtpd')->prop('RHSBL') eq 'enabled' ); + ( $cdb->get('qpsmtpd')->prop('RHSBL') eq 'enabled' ); my $DNSenabled = - ( esmith::ConfigDB->open_ro->get('qpsmtpd')->prop('DNSBL') eq 'enabled' ); + ( $cdb->get('qpsmtpd')->prop('DNSBL') eq 'enabled' ); my $SARejectLevel = - esmith::ConfigDB->open_ro->get('spamassassin')->prop('RejectLevel'); + $cdb->get('spamassassin')->prop('RejectLevel'); my $SATagLevel = - esmith::ConfigDB->open_ro->get('spamassassin')->prop('TagLevel'); + $cdb->get('spamassassin')->prop('TagLevel'); my $DomainName = - esmith::ConfigDB->open_ro->get('DomainName')->value; + $cdb->get('DomainName')->value; # check that logterse is in use #my pluginfile = '/var/service/qpsmtpd/config/peers/0'; #and see if mailstats are disabled -if (esmith::ConfigDB->open_ro->get('mailstats')){ - $disabled = !((esmith::ConfigDB->open_ro->get('mailstats')->prop('Status') || 'enabled') eq 'enabled'); +if ($cdb->get('mailstats')){ + $disabled = !(($cdb->get('mailstats')->prop('Status') || 'enabled') eq 'enabled'); } else { my $db = esmith::ConfigDB->open; my $record = $db->new_record('mailstats', { type => 'report', Status => 'enabled' }); $disabled = $false; } # check mailstats email recipient -my $email = esmith::ConfigDB->open_ro->get('mailstats')->prop('Email') || 'admin'; +my $email = $cdb->get('mailstats')->prop('Email') || 'admin'; $opt{'mail'} = $email; @@ -317,8 +320,8 @@ $ncateg = 0; while ( $ncateg < @categs) { $counts{$GRANDTOTAL}{$categs[$ncateg]} = 0; - if (esmith::ConfigDB->open_ro->get('mailstats')){ - $display[$ncateg] = lc(esmith::ConfigDB->open_ro->get('mailstats')->prop($categs[$ncateg])) || "auto"; + if ($cdb->get('mailstats')){ + $display[$ncateg] = lc($cdb->get('mailstats')->prop($categs[$ncateg])) || "auto"; } else { $display[$ncateg] = 'auto' } @@ -905,10 +908,10 @@ my $enableqpsmtpdcodes; my $enableSARules; my $enablejunkMailList; - if (esmith::ConfigDB->open_ro->get('mailstats')){ - $enableqpsmtpdcodes = esmith::ConfigDB->open_ro->get('mailstats')->prop("QpsmtpdCodes") || "enabled" eq "enabled" || $true; - $enableSARules = esmith::ConfigDB->open_ro->get('mailstats')->prop("SARules") || "enabled" eq "enabled" || $true; - $enablejunkMailList = esmith::ConfigDB->open_ro->get('mailstats')->prop("JunkMailList") || "enabled" eq "enabled" || $true; + if ($cdb->get('mailstats')){ + $enableqpsmtpdcodes = $cdb->get('mailstats')->prop("QpsmtpdCodes") || "enabled" eq "enabled" || $true; + $enableSARules = $cdb->get('mailstats')->prop("SARules") || "enabled" eq "enabled" || $true; + $enablejunkMailList = $cdb->get('mailstats')->prop("JunkMailList") || "enabled" eq "enabled" || $true; } else { $enableqpsmtpdcodes = $true; $enableSARules = $true; @@ -1070,8 +1073,8 @@ } else { $defaultpercentthreshold = $mincutoff } - if (esmith::ConfigDB->open_ro->get('mailstats')){ - $percentthreshold = esmith::ConfigDB->open_ro->get('mailstats')->prop("SARulePercentThreshold") || $defaultpercentthreshold; + if ($cdb->get('mailstats')){ + $percentthreshold = $cdb->get('mailstats')->prop("SARulePercentThreshold") || $defaultpercentthreshold; } else { $percentthreshold = $defaultpercentthreshold }