X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=blobdiff_plain;f=bin%2Fgatherstats.pl;h=c85b23de435e15901ef7e91c5e102940360991b6;hp=92d054522596065d927318f338e491948d6c22a7;hb=24d2011f322ff3b58527c24bbd767cdf02515ca5;hpb=dfc2b81c37c38c2b7bcc8afeead0ec927845b90f diff --git a/bin/gatherstats.pl b/bin/gatherstats.pl index 92d0545..c85b23d 100755 --- a/bin/gatherstats.pl +++ b/bin/gatherstats.pl @@ -13,7 +13,7 @@ # which Perl itself is published. BEGIN { - our $VERSION = "0.01"; + our $VERSION = "0.02"; use File::Basename; # we're in .../bin, so our module is in ../lib push(@INC, dirname($0).'/../lib'); @@ -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 @@ -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 @@ -410,7 +417,7 @@ Thomas Hochstein =head1 COPYRIGHT AND LICENSE -Copyright (c) 2010-2012 Thomas Hochstein +Copyright (c) 2010-2013 Thomas Hochstein This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.