no comment.... :-D

David Stiller schrieb:
Ok, if you can use PHP-CLI, try the attached scripts. Move arg_parse into
/usr/lib/php-cli/ or change the path in the main-script. Then you can use it
like this:

./spamdyke-domrep-cli -d example.com
example.com
-------------------------
DENIED_RDNS_MISSING:  490
TRAFFIC:  1728
DENIED:  1498
DENIED_RBL_MATCH:  372
DENIED_RDNS_RESOLVE:  384
ALLOWED:  452
DENIED_GRAYLISTED:  236
TIMEOUT:  4
DENIED_OTHER:  12
DENIED_SENDER_NO_MX:  4


Or for all with paging:
./spamdyke-domrep-cli -a | less

This is the analysis-routine used for my plesk-module.
So probably will work for you.

Greetz,
David



Peter schrieb:
Am Montag, den 03.11.2008, 16:06 +0100 schrieb David Stiller:
Yes, probably the log-file-format doesn't fit. That spamdyke-stats.pl parses the default-format of qmail. Plesk writes another. The qmail-SMTP-Logs normally
begin with:

@4000000048ee184815c9cc04

and Plesk write human-readables:

Nov  3 16:08:07 plesk-mail [...]

Sometime ago it had worked, but I am unshure what changed in past.
:(

It looks like:
Nov  3 15:48:11 server spamdyke[26334]: ALLOWED from: [EMAIL PROTECTED] to:
[EMAIL PROTECTED] origin_ip: 217.72.192.242 origin_rdns: fmmailgate04.web.de
auth: (unknown)

- Peter


_______________________________________________
spamdyke-users mailing list
[email protected]
http://www.spamdyke.org/mailman/listinfo/spamdyke-users



--
BLACKBIT neue Medien GmbH | BLACKBIT neue Werbung GmbH
Technischer Support/ Hotline
Ernst-Ruhstrat-Straße 6 - D-37079 Göttingen

Geschäftsführer: Stefano Viani
Registergericht: Amtsgericht Göttingen,  HRB 3222
Umsatzsteueridentifikationsnummer (§ 27a UstG): DE 813 114 917

Tel: +49-551-50675-50 - Fax: +49-551-50675-20
E-Mail: [EMAIL PROTECTED]

Klassische Werbung und Online-Marketing: http://www.blackbit.de
Software fuer Online-Marketing: http://www.go-community.de

argc = $argc; $this->argv = $argv; $this->parsed = array(); array_push($this->parsed, array($this->argv[0]) ); if ( !empty($force_this) ) if ( is_array($force_this) ) $this->force_this = $force_this; //Sending parameters to $parsed if ( $this->argc > 1 ) { for($i=1 ; $i< $this->argc ; $i++) { //We only have passed -xxxx if ( substr($this->argv[$i],0,1) == "-" ) { //Se temos -xxxx xxxx if ( $this->argc > ($i+1) ) { if ( substr($this->argv[$i+1],0,1) != "-" ) { array_push($this->parsed, array($this->argv[$i], $this->argv[$i+1]) ); $i++; continue; } } } //We have passed -xxxxx1 xxxxx2 array_push($this->parsed, array($this->argv[$i]) ); } } //Testing if all necessary parameters have been passed $this->force(); } //Testing if one parameter have benn passed function passed($argumento) { for($i=0 ; $i< $this->argc ; $i++) if ( $this->parsed[$i][0] == $argumento ) return $i; return 0; } //Testing if you have passed a estra argument, -xxxx1 xxxxx2 function full_passed($argumento) { $findArg = $this->passed($argumento); if ( $findArg ) if ( count($this->parsed[$findArg] ) > 1 ) return $findArg; return 0; } //Returns xxxxx2 at a " -xxxx1 xxxxx2" call function get_full_passed($argumento) { $findArg = $this->full_passed($argumento); if ( $findArg ) return $this->parsed[$findArg][1]; return; } //Necessary parameters to script function force() { if ( is_array( $this->force_this ) ) { for($i=0 ; $i< count($this->force_this) ; $i++) { if ( $this->force_this[$i][1] == "SIMPLE" && !$this->passed($this->force_this[$i][0]) ) // die("\n\nMissing " . $this->force_this[$i][0] . "\n\n"); if ( $this->force_this[$i][1] == "FULL" && !$this->full_passed($this->force_this[$i][0]) ) die("\n\nMissing " . $this->force_this[$i][0] ." \n\n"); } } } } /* //Example $forcar = array( array("-name", "FULL"), array("-email","SIMPLE") ); $parser = new arg_parser($forcar); if ( $parser->passed("-show") ) echo "\nGoing...:"; echo "\nName: " . $parser->get_full_passed("-name"); if ( $parser->full_passed("-email") ) echo "\nEmail: " . $parser->get_full_passed("-email"); else echo "\nEmail: default"; if ( $parser->full_passed("-copy") ) echo "\nCopy To: " . $parser->get_full_passed("-copy"); echo "\n\n"; */ $parser = new arg_parser(); ?>
#!/usr/bin/php5
<?php
include ("/usr/lib/php-cli/arg_parse.php");

$parser = new arg_parser();

$filename = "/var/log/mail";
if ( $parser->full_passed("-f")) {
        if (file_exists($parser->get_full_passed("-f"))) {
                echo "Parsing file ".$parser->get_full_passed("-f")."\n";       
                $filename = $parser->get_full_passed("-f");
        } else {
                die ("File not found \"".$parser->get_full_passed("-f")."\"\n");
        }
}

$fh = fopen($filename, "r", "");
if (!$fh) {
        die ("Could not open \"".$filename."\"");
        fclose($fh);
}
$today_stamp =  mktime (0,0,0,date("m"), date("d"), date("Y"));

if ($parser->passed("-d") || $parser->passed("-a")) {
        if ($parser->passed("-d")) {
                $pdomain = $parser->get_full_passed("-d");
        }
} else {
        die ("Please pass a domain with \"-d\" or create report for all domains 
with \"-a\".\n");
}

while ($line = fgets($fh, 4096)) {
        $spamdyke = stripos($line, "spamdyke"); 
        if ($spamdyke !== false) {
                //Extract DENY/ALLOW-Stats 
                $dyke = explode(" ", $line); 
                $dom = explode("@", $dyke[10]);

                $domkey = array_search('to:', $dyke);
                $stakey = array_search('from:', $dyke);

                $dom = explode("@", $dyke[$domkey+1]);
                $domain = $dom[1];
                $sts = explode(" ", $dyke[$stakey-1]);
                $status = $sts[0];

                if ($domain == $pdomain) {
                        $DOM[$domain][$status] += 1;
                        $DOM[$domain]['NAME'] = $domain;
                        $DOM[$domain]['TRAFFIC'] += 1;
        
                        $DENIED = stripos($status, "DENIED");
                        if ($DENIED !== false) {
                                $DOM[$domain]['DENIED'] += 1;
                        } else {
                                $ALLOWED = stripos($status, "ALLOWED");
                                if ($ALLOWED !== false) {
                                        $DOM[$domain]['ALLOWED'] += 1;
                                }       
                        }
                        $domfound = 1;
                } else {
                        //Double routine to speed up for single domain
                        if ($parser->passed("-a")) {
                                $DOM[$domain][$status] += 1;
                                $DOM[$domain]['NAME'] = $domain;
                                $DOM[$domain]['TRAFFIC'] += 1;

                                $DENIED = stripos($status, "DENIED");
                                if ($DENIED !== false) {
                                        $DOM[$domain]['DENIED'] += 1;
                                } else {
                                        $ALLOWED = stripos($status, "ALLOWED");
                                        if ($ALLOWED !== false) {
                                                $DOM[$domain]['ALLOWED'] += 1;
                                        }
                                }
                        } 
                }
                        
        }
}
fclose($fh);

// CLI
if ($parser->full_passed("-d")) {
        if ($domfound) {
                //Create report for single domain
                echo $DOM[$pdomain]['NAME']."\n";
                echo "-------------------------\n";
                while (list($key, $val) = each($DOM[$pdomain]))
                {
                        if ($key != "NAME")
                                echo "$key:  $val\n";

                        if ($key == "DENIED")
                                $DENIED += $val;

                        if ($key == "ALLOWED")
                                $ALLOWED += $val;

                        if ($key == "TRAFFIC")
                                $TRAFFIC += $val;
                }
                //print_r ($DOM[$pdomain]);  //DEBUG
        } else {
                die ('There was no traffic for "'.$pdomain.'" today.'."\n");
        }
                

}
if ($parser->passed("-a")) {
        //Create reports for all domains
        foreach ($DOM as $Domain) {
                echo $Domain['NAME']."\n";
                echo "-------------------------\n";
                while (list($key, $val) = each($Domain))
                {
                        if ($key != "NAME") 
                                echo "$key:  $val\n";
                        
                        if ($key == "DENIED")
                                $DENIED += $val;
                        
                        if ($key == "ALLOWED")
                                $ALLOWED += $val;

                        if ($key == "TRAFFIC")
                                $TRAFFIC += $val;
                        
                }
                echo "\n";
        }

}
if ($parser->passed("-r")) {
        //Create summary report
        echo "Mails handled: ".number_format($TRAFFIC, 0, ',', '.')."\n";
        echo "ALLOWED TOTAL: ".number_format($ALLOWED, 0, ',', '.')."\n";
        echo "DENIED TOTAL:  ".number_format($DENIED, 0, ',', '.')."\n";
        $SPAMP = $DENIED/$TRAFFIC*100;
        echo "SPAM % ".round($SPAMP,2);
}
echo "\n";


?>
_______________________________________________
spamdyke-users mailing list
[email protected]
http://www.spamdyke.org/mailman/listinfo/spamdyke-users

Reply via email to