X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=blobdiff_plain;f=bin%2Fgatherstats.pl;h=a5a486a19958c9759679a94e63c722d039f0dbf6;hp=f545456478a470505d79a3478517ceba21650789;hb=8dc6823e988b8828454f6ef1ea2b43e3e0cc5a20;hpb=2ad99c20bcc297362aeccabb1c51e20c4bd4b533 diff --git a/bin/gatherstats.pl b/bin/gatherstats.pl index f545456..a5a486a 100755 --- a/bin/gatherstats.pl +++ b/bin/gatherstats.pl @@ -4,12 +4,12 @@ # # This script will gather statistical information from a database # containing headers and other information from a INN feed. -# +# # It is part of the NewsStats package. # # Copyright (c) 2010-2013 Thomas Hochstein # -# It can be redistributed and/or modified under the same terms under +# It can be redistributed and/or modified under the same terms under # which Perl itself is published. BEGIN { @@ -38,7 +38,7 @@ my %LegalStats; ### read commandline options my ($OptCheckgroupsFile,$OptClientsDB,$OptDebug,$OptGroupsDB,$OptTLH, - $OptHostsDB,$OptMonth,$OptRawDB,$OptStatsType,$OptTest); + $OptHostsDB,$OptMonth,$OptRawDB,$OptStatsType,$OptTest,$OptConfFile); GetOptions ('c|checkgroups=s' => \$OptCheckgroupsFile, 'clientsdb=s' => \$OptClientsDB, 'd|debug!' => \$OptDebug, @@ -49,11 +49,12 @@ GetOptions ('c|checkgroups=s' => \$OptCheckgroupsFile, 'rawdb=s' => \$OptRawDB, 's|stats=s' => \$OptStatsType, 't|test!' => \$OptTest, + 'conffile=s' => \$OptConfFile, 'h|help' => \&ShowPOD, 'V|version' => \&ShowVersion) or exit 1; ### read configuration -my %Conf = %{ReadConfig('')}; +my %Conf = %{ReadConfig($OptConfFile)}; ### override configuration via commandline options my %ConfOverride; @@ -72,6 +73,8 @@ $OptStatsType = 'all' if !$OptStatsType; ### get time period from --month # get verbal description of time period, drop SQL code my ($Period) = &GetTimePeriod($OptMonth); +# bail out if --month is invalid or set to 'ALL'; +# we don't support the latter &Bleat(2,"--month option has an invalid format - please use 'YYYY-MM' or ". "'YYYY-MM:YYYY-MM'!") if (!$Period or $Period eq 'all time'); @@ -161,7 +164,7 @@ foreach my $Month (&ListMonth($Period)) { } }; }; - + # delete old data for that month if (!$OptTest) { $DBQuery = $DBHandle->do(sprintf("DELETE FROM %s.%s WHERE month = ?", @@ -207,7 +210,7 @@ gatherstats - process statistical data from a raw source =head1 SYNOPSIS -B [B<-Vhdt>] [B<-m> I | I] [B<-s> I] [B<-c> I]] [B<--hierarchy> I] [B<--rawdb> I] [B<-groupsdb> I] [B<--clientsdb> I] [B<--hostsdb> I] +B [B<-Vhdt>] [B<-m> I | I] [B<-s> I] [B<-c> I]] [B<--hierarchy> I] [B<--rawdb> I] [B<-groupsdb> I] [B<--clientsdb> I] [B<--hostsdb> I] [--conffile I] =head1 REQUIREMENTS @@ -292,7 +295,7 @@ conjunction with B<--test> ... everything else seems a bit pointless. Set processing period to a single month in YYYY-MM format or to a time period between two month in YYYY-MM:YYYY-MM format (two month, separated -by a colon). +by a colon). =item B<-s>, B<--stats> I @@ -340,6 +343,10 @@ Override I from F. Override I from F. +=item B<--conffile> I + +Load configuration from I instead of F. + =back =head1 INSTALLATION