/[smecontribs]/rpms/smeserver-mailstats/contribs7/smeserver-mailstats-0.0.3-implementDBCreation.patch
ViewVC logotype

Annotation of /rpms/smeserver-mailstats/contribs7/smeserver-mailstats-0.0.3-implementDBCreation.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Sat Oct 4 08:46:59 2008 UTC (16 years, 1 month ago) by snetram
Branch: MAIN
CVS Tags: smeserver-mailstats-0_0_3-11_el4_sme
* Sat Oct  4 2008 Jonathan Martens <smeserver-contribs@snetram.nl> 0.0.3-11
- Implement MySQL database creation [SME: 4275]
- Remove changelog from spamfilter-stats script

1 snetram 1.1 --- smeserver-mailstats-0.0.3/root/usr/bin/spamfilter-stats-7.pl.implementDBCreation 2008-10-04 10:25:00.000000000 +0200
2     +++ smeserver-mailstats-0.0.3/root/usr/bin/spamfilter-stats-7.pl 2008-10-04 10:36:33.000000000 +0200
3     @@ -115,155 +115,6 @@
4     # / Interval - "day", "week", "fortnight", "month", "99999" - last is number of seconds (default is day)
5     # / Base - "Midnight", "Midday", "Now", "99" hour (0-23) (default is midnight)
6     #
7     -#############################################################################
8     -#
9     -# Table structure for MySQL table for saving data
10     -#
11     -# Database : `mailstats`
12     -#
13     -# use mailstats;
14     -# --------------------------------------------------------
15     -
16     -#
17     -# Table structure for table `ColumnStats`
18     -#
19     -#
20     -#CREATE TABLE `ColumnStats` (
21     -# `ColumnStatsid` int(11) NOT NULL auto_increment,
22     -# `dateid` int(11) NOT NULL default '0',
23     -# `timeid` int(11) NOT NULL default '0',
24     -# `descr` varchar(20) NOT NULL default '',
25     -# `count` bigint(20) NOT NULL default '0',
26     -# `servername` varchar(30) NOT NULL default '',
27     -# PRIMARY KEY (`ColumnStatsid`)
28     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
29     -
30     -# --------------------------------------------------------
31     -
32     -#
33     -# Table structure for table `JunkMailStats`
34     -#
35     -
36     -#CREATE TABLE `JunkMailStats` (
37     -# `JunkMailstatsid` int(11) NOT NULL auto_increment,
38     -# `dateid` int(11) NOT NULL default '0',
39     -# `user` varchar(12) NOT NULL default '',
40     -# `count` bigint(20) NOT NULL default '0',
41     -# `servername` varchar(30) default NULL,
42     -# PRIMARY KEY (`JunkMailstatsid`)
43     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
44     -#
45     -# --------------------------------------------------------
46     -
47     -#
48     -# Table structure for table `SARules`
49     -#
50     -
51     -#CREATE TABLE `SARules` (
52     -# `SARulesid` int(11) NOT NULL auto_increment,
53     -# `dateid` int(11) NOT NULL default '0',
54     -# `rule` varchar(50) NOT NULL default '',
55     -# `count` bigint(20) NOT NULL default '0',
56     -# `totalhits` bigint(20) NOT NULL default '0',
57     -# `servername` varchar(30) NOT NULL default '',
58     -# PRIMARY KEY (`SARulesid`)
59     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
60     -
61     -# --------------------------------------------------------
62     -
63     -#
64     -# Table structure for table `SAscores`
65     -#
66     -
67     -#CREATE TABLE `SAscores` (
68     -# `SAscoresid` int(11) NOT NULL auto_increment,
69     -# `dateid` int(11) NOT NULL default '0',
70     -# `acceptedcount` bigint(20) NOT NULL default '0',
71     -# `rejectedcount` bigint(20) NOT NULL default '0',
72     -# `hamcount` bigint(20) NOT NULL default '0',
73     -# `acceptedscore` decimal(20,2) NOT NULL default '0.00',
74     -# `rejectedscore` decimal(20,2) NOT NULL default '0.00',
75     -# `hamscore` decimal(20,2) NOT NULL default '0.00',
76     -# `totalsmtp` bigint(20) NOT NULL default '0',
77     -# `totalrecip` bigint(20) NOT NULL default '0',
78     -# `servername` varchar(30) NOT NULL default '',
79     -# PRIMARY KEY (`SAscoresid`)
80     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
81     -
82     -# --------------------------------------------------------
83     -
84     -#
85     -# Table structure for table `VirusStats`
86     -#
87     -
88     -#CREATE TABLE `VirusStats` (
89     -# `VirusStatsid` int(11) NOT NULL auto_increment,
90     -# `dateid` int(11) NOT NULL default '0',
91     -# `descr` varchar(40) NOT NULL default '',
92     -# `count` bigint(20) NOT NULL default '0',
93     -# `servername` varchar(30) NOT NULL default '',
94     -# PRIMARY KEY (`VirusStatsid`)
95     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
96     -#
97     -# --------------------------------------------------------
98     -
99     -#
100     -# Table structure for table `date`
101     -#
102     -
103     -#CREATE TABLE `date` (
104     -# `dateid` int(11) NOT NULL auto_increment,
105     -# `date` date NOT NULL default '0000-00-00',
106     -# PRIMARY KEY (`dateid`)
107     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
108     -#
109     -# --------------------------------------------------------
110     -
111     -#
112     -# Table structure for table `domains`
113     -#
114     -
115     -#CREATE TABLE `domains` (
116     -# `domainsid` int(11) NOT NULL auto_increment,
117     -# `dateid` int(11) NOT NULL default '0',
118     -# `domain` varchar(40) NOT NULL default '',
119     -# `type` varchar(10) NOT NULL default '',
120     -# `total` bigint(20) NOT NULL default '0',
121     -# `denied` bigint(20) NOT NULL default '0',
122     -# `xfererr` bigint(20) NOT NULL default '0',
123     -# `accept` bigint(20) NOT NULL default '0',
124     -# `servername` varchar(30) NOT NULL default '',
125     -# PRIMARY KEY (`domainsid`)
126     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
127     -
128     -# --------------------------------------------------------
129     -
130     -#
131     -# Table structure for table `qpsmtpdcodes`
132     -#
133     -
134     -#CREATE TABLE `qpsmtpdcodes` (
135     -# `qpsmtpdcodesid` int(11) NOT NULL auto_increment,
136     -# `dateid` int(11) NOT NULL default '0',
137     -# `reason` varchar(40) NOT NULL default '',
138     -# `count` bigint(20) NOT NULL default '0',
139     -# `servername` varchar(30) NOT NULL default '',
140     -# PRIMARY KEY (`qpsmtpdcodesid`)
141     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
142     -
143     -# --------------------------------------------------------
144     -
145     -#
146     -# Table structure for table `time`
147     -#
148     -
149     -#CREATE TABLE `time` (
150     -# `timeid` int(11) NOT NULL auto_increment,
151     -# `time` time NOT NULL default '00:00:00',
152     -# PRIMARY KEY (`timeid`)
153     -#) ENGINE=MyISAM DEFAULT CHARSET=latin1;
154     -#
155     -#############################################################################
156    
157     # internal modules (part of core perl distribution)
158     use strict;
159     @@ -1361,7 +1212,7 @@
160     # now fill in day related stats - must always check for it already there
161     # incase the module is run more than once in a day
162     my $SAScoresid = check_date_rec($dbh,"SAscores",$dateid,$servername);
163     - $dbh->do( "UPDATE SAscores SET ".
164     + $dbh->do( "UPDATE sascores SET ".
165     "acceptedcount=".$spamcount.
166     ",rejectedcount=".$above15.
167     ",hamcount=".$hamcount.
168     @@ -1374,19 +1225,19 @@
169     "' WHERE SAscoresid =".$SAScoresid);
170     # Junkmail stats
171     # delete if already there
172     - $dbh->do("DELETE from JunkMailStats WHERE dateid = ".$dateid." AND servername='".$servername."'");
173     + $dbh->do("DELETE from junkmailstats WHERE dateid = ".$dateid." AND servername='".$servername."'");
174     # and add records
175     foreach my $thisuser (keys %junkcount){
176     - $dbh->do("INSERT INTO JunkMailStats (dateid,user,count,servername) VALUES ('".
177     + $dbh->do("INSERT INTO junkmailstats (dateid,user,count,servername) VALUES ('".
178     $dateid."','".$thisuser."','".$junkcount{$thisuser}."','".$servername."')");
179     $reccount++;
180     }
181     #SA rules - delete any first
182     - $dbh->do("DELETE from SARules WHERE dateid = ".$dateid." AND servername='".$servername."'");
183     + $dbh->do("DELETE from sarules WHERE dateid = ".$dateid." AND servername='".$servername."'");
184     # and add records
185     foreach my $thisrule (keys %found_SARules){
186     - $dbh->do("INSERT INTO SARules (dateid,rule,count,totalhits,servername) VALUES ('".
187     - $dateid."','".$thisrule."','".$found_SARules{$thisrule}{'count'}."','".
188     + $dbh->do("INSERT INTO sarules (dateid,rule,count,totalhits,servername) VALUES ('".
189     + $dateid."','".$thisrule."','".$found_sarules{$thisrule}{'count'}."','".
190     $found_SARules{$thisrule}{'totalhits'}."','".$servername."')");
191     $reccount++;
192     }
193     @@ -1399,10 +1250,10 @@
194     $reccount++;
195     }
196     # virus stats
197     - $dbh->do("DELETE from VirusStats WHERE dateid = ".$dateid." AND servername='".$servername."'");
198     + $dbh->do("DELETE from virusstats WHERE dateid = ".$dateid." AND servername='".$servername."'");
199     # and add records
200     foreach my $thisvirus (keys %found_viruses){
201     - $dbh->do("INSERT INTO VirusStats (dateid,descr,count,servername) VALUES ('".
202     + $dbh->do("INSERT INTO virusstats (dateid,descr,count,servername) VALUES ('".
203     $dateid."','".$thisvirus."','".$found_viruses{$thisvirus}."','".$servername."')");
204     $reccount++;
205    
206     @@ -1453,17 +1304,17 @@
207     $reportdate = $currentdate;
208     }
209     # delete for this date and time
210     - $dbh->do("DELETE from ColumnStats WHERE dateid = ".$dateid." AND timeid = ".$timeid." AND servername='".$servername."'");
211     + $dbh->do("DELETE from columnstats WHERE dateid = ".$dateid." AND timeid = ".$timeid." AND servername='".$servername."'");
212     while ( $ncateg < @categs-1 ) {
213     # then add in each entry
214     if (($counts{$nhour}{$categs[$ncateg]} || 0) != 0) {
215     - $dbh->do("INSERT INTO ColumnStats (dateid,timeid,descr,count,servername) VALUES ("
216     + $dbh->do("INSERT INTO columnstats (dateid,timeid,descr,count,servername) VALUES ("
217     .$dateid.",".$timeid.",'".$categs[$ncateg]."',"
218     .$counts{$nhour}{$categs[$ncateg]}.",'".$servername."')");
219     $reccount++;
220     }
221    
222     -# print("INSERT INTO ColumnStats (dateid,timeid,descr,count) VALUES ("
223     +# print("INSERT INTO columnstats (dateid,timeid,descr,count) VALUES ("
224     # .$dateid.",".$timeid.",'".$categs[$ncateg]."',"
225     # .$counts{$nhour}{$categs[$ncateg]}.")\n");
226    
227     --- 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
228     +++ 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
229     @@ -0,0 +1,90 @@
230     +IF NOT EXISTS CREATE DATABASE `mailstats`;
231     +
232     +USE `mailstats`;
233     +
234     +IF NOT EXISTS CREATE TABLE `columnstats` (
235     + `ColumnStatsid` int(11) NOT NULL auto_increment,
236     + `dateid` int(11) NOT NULL default '0',
237     + `timeid` int(11) NOT NULL default '0',
238     + `descr` varchar(20) NOT NULL default '',
239     + `count` bigint(20) NOT NULL default '0',
240     + `servername` varchar(30) NOT NULL default '',
241     + PRIMARY KEY (`ColumnStatsid`)
242     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
243     +
244     +IF NOT EXISTS CREATE TABLE `junkmailstats` (
245     + `JunkMailstatsid` int(11) NOT NULL auto_increment,
246     + `dateid` int(11) NOT NULL default '0',
247     + `user` varchar(12) NOT NULL default '',
248     + `count` bigint(20) NOT NULL default '0',
249     + `servername` varchar(30) default NULL,
250     + PRIMARY KEY (`JunkMailstatsid`)
251     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
252     +
253     +IF NOT EXISTS CREATE TABLE `sarules` (
254     + `SARulesid` int(11) NOT NULL auto_increment,
255     + `dateid` int(11) NOT NULL default '0',
256     + `rule` varchar(50) NOT NULL default '',
257     + `count` bigint(20) NOT NULL default '0',
258     + `totalhits` bigint(20) NOT NULL default '0',
259     + `servername` varchar(30) NOT NULL default '',
260     + PRIMARY KEY (`SARulesid`)
261     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
262     +
263     +IF NOT EXISTS CREATE TABLE `sascores` (
264     + `SAscoresid` int(11) NOT NULL auto_increment,
265     + `dateid` int(11) NOT NULL default '0',
266     + `acceptedcount` bigint(20) NOT NULL default '0',
267     + `rejectedcount` bigint(20) NOT NULL default '0',
268     + `hamcount` bigint(20) NOT NULL default '0',
269     + `acceptedscore` decimal(20,2) NOT NULL default '0.00',
270     + `rejectedscore` decimal(20,2) NOT NULL default '0.00',
271     + `hamscore` decimal(20,2) NOT NULL default '0.00',
272     + `totalsmtp` bigint(20) NOT NULL default '0',
273     + `totalrecip` bigint(20) NOT NULL default '0',
274     + `servername` varchar(30) NOT NULL default '',
275     + PRIMARY KEY (`SAscoresid`)
276     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
277     +
278     +IF NOT EXISTS CREATE TABLE `virusstats` (
279     + `VirusStatsid` int(11) NOT NULL auto_increment,
280     + `dateid` int(11) NOT NULL default '0',
281     + `descr` varchar(40) NOT NULL default '',
282     + `count` bigint(20) NOT NULL default '0',
283     + `servername` varchar(30) NOT NULL default '',
284     + PRIMARY KEY (`VirusStatsid`)
285     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
286     +
287     +IF NOT EXISTS CREATE TABLE `date` (
288     + `dateid` int(11) NOT NULL auto_increment,
289     + `date` date NOT NULL default '0000-00-00',
290     + PRIMARY KEY (`dateid`)
291     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
292     +
293     +IF NOT EXISTS CREATE TABLE `domains` (
294     + `domainsid` int(11) NOT NULL auto_increment,
295     + `dateid` int(11) NOT NULL default '0',
296     + `domain` varchar(40) NOT NULL default '',
297     + `type` varchar(10) NOT NULL default '',
298     + `total` bigint(20) NOT NULL default '0',
299     + `denied` bigint(20) NOT NULL default '0',
300     + `xfererr` bigint(20) NOT NULL default '0',
301     + `accept` bigint(20) NOT NULL default '0',
302     + `servername` varchar(30) NOT NULL default '',
303     + PRIMARY KEY (`domainsid`)
304     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
305     +
306     +IF NOT EXISTS CREATE TABLE `qpsmtpdcodes` (
307     + `qpsmtpdcodesid` int(11) NOT NULL auto_increment,
308     + `dateid` int(11) NOT NULL default '0',
309     + `reason` varchar(40) NOT NULL default '',
310     + `count` bigint(20) NOT NULL default '0',
311     + `servername` varchar(30) NOT NULL default '',
312     + PRIMARY KEY (`qpsmtpdcodesid`)
313     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;
314     +
315     +IF NOT EXISTS CREATE TABLE `time` (
316     + `timeid` int(11) NOT NULL auto_increment,
317     + `time` time NOT NULL default '00:00:00',
318     + PRIMARY KEY (`timeid`)
319     +) ENGINE=MyISAM DEFAULT CHARSET=latin1;

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed