--- smeserver-mailstats-0.0.3/root/usr/bin/spamfilter-stats-7.pl.implementDBCreation 2008-10-04 10:25:00.000000000 +0200 +++ smeserver-mailstats-0.0.3/root/usr/bin/spamfilter-stats-7.pl 2008-10-04 10:36:33.000000000 +0200 @@ -115,155 +115,6 @@ # / Interval - "day", "week", "fortnight", "month", "99999" - last is number of seconds (default is day) # / Base - "Midnight", "Midday", "Now", "99" hour (0-23) (default is midnight) # -############################################################################# -# -# Table structure for MySQL table for saving data -# -# Database : `mailstats` -# -# use mailstats; -# -------------------------------------------------------- - -# -# Table structure for table `ColumnStats` -# -# -#CREATE TABLE `ColumnStats` ( -# `ColumnStatsid` int(11) NOT NULL auto_increment, -# `dateid` int(11) NOT NULL default '0', -# `timeid` int(11) NOT NULL default '0', -# `descr` varchar(20) NOT NULL default '', -# `count` bigint(20) NOT NULL default '0', -# `servername` varchar(30) NOT NULL default '', -# PRIMARY KEY (`ColumnStatsid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -# -------------------------------------------------------- - -# -# Table structure for table `JunkMailStats` -# - -#CREATE TABLE `JunkMailStats` ( -# `JunkMailstatsid` int(11) NOT NULL auto_increment, -# `dateid` int(11) NOT NULL default '0', -# `user` varchar(12) NOT NULL default '', -# `count` bigint(20) NOT NULL default '0', -# `servername` varchar(30) default NULL, -# PRIMARY KEY (`JunkMailstatsid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -# -# -------------------------------------------------------- - -# -# Table structure for table `SARules` -# - -#CREATE TABLE `SARules` ( -# `SARulesid` int(11) NOT NULL auto_increment, -# `dateid` int(11) NOT NULL default '0', -# `rule` varchar(50) NOT NULL default '', -# `count` bigint(20) NOT NULL default '0', -# `totalhits` bigint(20) NOT NULL default '0', -# `servername` varchar(30) NOT NULL default '', -# PRIMARY KEY (`SARulesid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -# -------------------------------------------------------- - -# -# Table structure for table `SAscores` -# - -#CREATE TABLE `SAscores` ( -# `SAscoresid` int(11) NOT NULL auto_increment, -# `dateid` int(11) NOT NULL default '0', -# `acceptedcount` bigint(20) NOT NULL default '0', -# `rejectedcount` bigint(20) NOT NULL default '0', -# `hamcount` bigint(20) NOT NULL default '0', -# `acceptedscore` decimal(20,2) NOT NULL default '0.00', -# `rejectedscore` decimal(20,2) NOT NULL default '0.00', -# `hamscore` decimal(20,2) NOT NULL default '0.00', -# `totalsmtp` bigint(20) NOT NULL default '0', -# `totalrecip` bigint(20) NOT NULL default '0', -# `servername` varchar(30) NOT NULL default '', -# PRIMARY KEY (`SAscoresid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -# -------------------------------------------------------- - -# -# Table structure for table `VirusStats` -# - -#CREATE TABLE `VirusStats` ( -# `VirusStatsid` int(11) NOT NULL auto_increment, -# `dateid` int(11) NOT NULL default '0', -# `descr` varchar(40) NOT NULL default '', -# `count` bigint(20) NOT NULL default '0', -# `servername` varchar(30) NOT NULL default '', -# PRIMARY KEY (`VirusStatsid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -# -# -------------------------------------------------------- - -# -# Table structure for table `date` -# - -#CREATE TABLE `date` ( -# `dateid` int(11) NOT NULL auto_increment, -# `date` date NOT NULL default '0000-00-00', -# PRIMARY KEY (`dateid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -# -# -------------------------------------------------------- - -# -# Table structure for table `domains` -# - -#CREATE TABLE `domains` ( -# `domainsid` int(11) NOT NULL auto_increment, -# `dateid` int(11) NOT NULL default '0', -# `domain` varchar(40) NOT NULL default '', -# `type` varchar(10) NOT NULL default '', -# `total` bigint(20) NOT NULL default '0', -# `denied` bigint(20) NOT NULL default '0', -# `xfererr` bigint(20) NOT NULL default '0', -# `accept` bigint(20) NOT NULL default '0', -# `servername` varchar(30) NOT NULL default '', -# PRIMARY KEY (`domainsid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -# -------------------------------------------------------- - -# -# Table structure for table `qpsmtpdcodes` -# - -#CREATE TABLE `qpsmtpdcodes` ( -# `qpsmtpdcodesid` int(11) NOT NULL auto_increment, -# `dateid` int(11) NOT NULL default '0', -# `reason` varchar(40) NOT NULL default '', -# `count` bigint(20) NOT NULL default '0', -# `servername` varchar(30) NOT NULL default '', -# PRIMARY KEY (`qpsmtpdcodesid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -# -------------------------------------------------------- - -# -# Table structure for table `time` -# - -#CREATE TABLE `time` ( -# `timeid` int(11) NOT NULL auto_increment, -# `time` time NOT NULL default '00:00:00', -# PRIMARY KEY (`timeid`) -#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -# -############################################################################# # internal modules (part of core perl distribution) use strict; @@ -1361,7 +1212,7 @@ # now fill in day related stats - must always check for it already there # incase the module is run more than once in a day my $SAScoresid = check_date_rec($dbh,"SAscores",$dateid,$servername); - $dbh->do( "UPDATE SAscores SET ". + $dbh->do( "UPDATE sascores SET ". "acceptedcount=".$spamcount. ",rejectedcount=".$above15. ",hamcount=".$hamcount. @@ -1374,19 +1225,19 @@ "' WHERE SAscoresid =".$SAScoresid); # Junkmail stats # delete if already there - $dbh->do("DELETE from JunkMailStats WHERE dateid = ".$dateid." AND servername='".$servername."'"); + $dbh->do("DELETE from junkmailstats WHERE dateid = ".$dateid." AND servername='".$servername."'"); # and add records foreach my $thisuser (keys %junkcount){ - $dbh->do("INSERT INTO JunkMailStats (dateid,user,count,servername) VALUES ('". + $dbh->do("INSERT INTO junkmailstats (dateid,user,count,servername) VALUES ('". $dateid."','".$thisuser."','".$junkcount{$thisuser}."','".$servername."')"); $reccount++; } #SA rules - delete any first - $dbh->do("DELETE from SARules WHERE dateid = ".$dateid." AND servername='".$servername."'"); + $dbh->do("DELETE from sarules WHERE dateid = ".$dateid." AND servername='".$servername."'"); # and add records foreach my $thisrule (keys %found_SARules){ - $dbh->do("INSERT INTO SARules (dateid,rule,count,totalhits,servername) VALUES ('". - $dateid."','".$thisrule."','".$found_SARules{$thisrule}{'count'}."','". + $dbh->do("INSERT INTO sarules (dateid,rule,count,totalhits,servername) VALUES ('". + $dateid."','".$thisrule."','".$found_sarules{$thisrule}{'count'}."','". $found_SARules{$thisrule}{'totalhits'}."','".$servername."')"); $reccount++; } @@ -1399,10 +1250,10 @@ $reccount++; } # virus stats - $dbh->do("DELETE from VirusStats WHERE dateid = ".$dateid." AND servername='".$servername."'"); + $dbh->do("DELETE from virusstats WHERE dateid = ".$dateid." AND servername='".$servername."'"); # and add records foreach my $thisvirus (keys %found_viruses){ - $dbh->do("INSERT INTO VirusStats (dateid,descr,count,servername) VALUES ('". + $dbh->do("INSERT INTO virusstats (dateid,descr,count,servername) VALUES ('". $dateid."','".$thisvirus."','".$found_viruses{$thisvirus}."','".$servername."')"); $reccount++; @@ -1453,17 +1304,17 @@ $reportdate = $currentdate; } # delete for this date and time - $dbh->do("DELETE from ColumnStats WHERE dateid = ".$dateid." AND timeid = ".$timeid." AND servername='".$servername."'"); + $dbh->do("DELETE from columnstats WHERE dateid = ".$dateid." AND timeid = ".$timeid." AND servername='".$servername."'"); while ( $ncateg < @categs-1 ) { # then add in each entry if (($counts{$nhour}{$categs[$ncateg]} || 0) != 0) { - $dbh->do("INSERT INTO ColumnStats (dateid,timeid,descr,count,servername) VALUES (" + $dbh->do("INSERT INTO columnstats (dateid,timeid,descr,count,servername) VALUES (" .$dateid.",".$timeid.",'".$categs[$ncateg]."'," .$counts{$nhour}{$categs[$ncateg]}.",'".$servername."')"); $reccount++; } -# print("INSERT INTO ColumnStats (dateid,timeid,descr,count) VALUES (" +# print("INSERT INTO columnstats (dateid,timeid,descr,count) VALUES (" # .$dateid.",".$timeid.",'".$categs[$ncateg]."'," # .$counts{$nhour}{$categs[$ncateg]}.")\n"); --- smeserver-mailstats-0.0.3/root/etc/e-smith/templates/etc/e-smith/sql/mailstats-create-schema.sql.implementDBCreation 2008-10-04 10:26:03.000000000 +0200 +++ smeserver-mailstats-0.0.3/root/etc/e-smith/templates/etc/e-smith/sql/mailstats-create-schema.sql 2008-10-04 10:30:51.000000000 +0200 @@ -0,0 +1,90 @@ +IF NOT EXISTS CREATE DATABASE `mailstats`; + +USE `mailstats`; + +IF NOT EXISTS CREATE TABLE `columnstats` ( + `ColumnStatsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `timeid` int(11) NOT NULL default '0', + `descr` varchar(20) NOT NULL default '', + `count` bigint(20) NOT NULL default '0', + `servername` varchar(30) NOT NULL default '', + PRIMARY KEY (`ColumnStatsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `junkmailstats` ( + `JunkMailstatsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `user` varchar(12) NOT NULL default '', + `count` bigint(20) NOT NULL default '0', + `servername` varchar(30) default NULL, + PRIMARY KEY (`JunkMailstatsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `sarules` ( + `SARulesid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `rule` varchar(50) NOT NULL default '', + `count` bigint(20) NOT NULL default '0', + `totalhits` bigint(20) NOT NULL default '0', + `servername` varchar(30) NOT NULL default '', + PRIMARY KEY (`SARulesid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `sascores` ( + `SAscoresid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `acceptedcount` bigint(20) NOT NULL default '0', + `rejectedcount` bigint(20) NOT NULL default '0', + `hamcount` bigint(20) NOT NULL default '0', + `acceptedscore` decimal(20,2) NOT NULL default '0.00', + `rejectedscore` decimal(20,2) NOT NULL default '0.00', + `hamscore` decimal(20,2) NOT NULL default '0.00', + `totalsmtp` bigint(20) NOT NULL default '0', + `totalrecip` bigint(20) NOT NULL default '0', + `servername` varchar(30) NOT NULL default '', + PRIMARY KEY (`SAscoresid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `virusstats` ( + `VirusStatsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `descr` varchar(40) NOT NULL default '', + `count` bigint(20) NOT NULL default '0', + `servername` varchar(30) NOT NULL default '', + PRIMARY KEY (`VirusStatsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `date` ( + `dateid` int(11) NOT NULL auto_increment, + `date` date NOT NULL default '0000-00-00', + PRIMARY KEY (`dateid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `domains` ( + `domainsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `domain` varchar(40) NOT NULL default '', + `type` varchar(10) NOT NULL default '', + `total` bigint(20) NOT NULL default '0', + `denied` bigint(20) NOT NULL default '0', + `xfererr` bigint(20) NOT NULL default '0', + `accept` bigint(20) NOT NULL default '0', + `servername` varchar(30) NOT NULL default '', + PRIMARY KEY (`domainsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `qpsmtpdcodes` ( + `qpsmtpdcodesid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `reason` varchar(40) NOT NULL default '', + `count` bigint(20) NOT NULL default '0', + `servername` varchar(30) NOT NULL default '', + PRIMARY KEY (`qpsmtpdcodesid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +IF NOT EXISTS CREATE TABLE `time` ( + `timeid` int(11) NOT NULL auto_increment, + `time` time NOT NULL default '00:00:00', + PRIMARY KEY (`timeid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1;