ispman/bin ispman.makelogs,1.23,1.24
Joerg Delker <[email protected]>
| Newsgroups | gmane.comp.isp.ispman.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ispman/ispman/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13221/bin
Modified Files:
ispman.makelogs
Log Message:
applied changes from TheSin
Index: ispman.makelogs
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.makelogs,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- ispman.makelogs 30 May 2004 23:35:32 -0000 1.23
+++ ispman.makelogs 20 Jun 2004 09:38:11 -0000 1.24
@@ -18,7 +18,6 @@
$vhostDirectory
$webalizer
$rawDirectory
- $logsDir
);
}
@@ -30,11 +29,9 @@
use ISPMan;
my $ispman = ISPMan->new();
-$logsDir = $ispman->getConf("apacheLogsDirectory");
$webalizer = $ispman->getConf("apacheWebalizerPath");
my $apacheGracefulCommand = $ispman->getConf("apacheGracefulCommand");
my $apacheGracefulTime = $ispman->getConf("apacheGracefulTime");
-$vhostsHashFile = join '.', ( $ispman->getConf("apacheVhostsFile"), "hash" );
# Basic Password security
#our $protectLogs=$ispman->getConf("protectLogs");
@@ -67,21 +64,46 @@
$apacheGracefulTime = 600;
}
-unless ( -e $logsDir ) {
- die "Logs directory $logsDir does not exists\n";
-}
-
unless ( -e $webalizer ) {
warn
"Webalizer command does not exists\nI will split the files but no reports will be generated.";
}
-if ( -e $vhostsHashFile ) {
- require $vhostsHashFile;
- $vhosts = $VAR1;
+if ( $ispman->getConf("ispmanVhostsStyle") =~ /dir/m ) {
+ print "Using one hash file per domain\n";
+ my ( $domain, $domains );
+
+ $domains = $ispman->makeDomainHash( $ispman->getDomains() );
+
+ $vhosts = "";
+ foreach $domain ( keys %$domains ) {
+ my $domainInfo = $ispman->getDomainInfo($domain);
+ unless ( $domainInfo->{'ispmanDomainType'} eq "replica" ) {
+ $vhostsHashFile =
+ join( "/", $ispman->getConf("apacheVhostsFile"), "hash", $domain )
+ . ".hash";
+ if ( -e $vhostsHashFile ) {
+ print "Loading $vhostsHashFile...\n";
+ require $vhostsHashFile;
+ $vhosts .= $VAR1;
+ }
+ else {
+ warn "No file found for $domain\n";
+ }
+ }
+ }
}
else {
- die "No VhostsHash file found $vhostsHashFile\n";
+ print "Using one hash file for all domains\n";
+ $vhostsHashFile = join '.',
+ ( $ispman->getConf("apacheVhostsFile"), "hash" );
+ if ( -e $vhostsHashFile ) {
+ require $vhostsHashFile;
+ $vhosts = $VAR1;
+ }
+ else {
+ die "No VhostsHash file found $vhostsHashFile\n";
+ }
}
if ( $ARGV[0] ) {
@@ -90,20 +112,26 @@
exit;
}
-print "Moving actual log files to new filename for closing open connections\n";
+print
+ "\nStart by moving current log files to new filename to avoiding writing\n";
+print "to them while we are working with em.\n";
processAllServers("moveLogsForClose");
-print "Now we tell the Apache to start to write to new logfiles\n";
print
-"Open connections will be logged to temporary logfiles for the next Minutes\n";
+"\nNow lets restart the webserver to open new logfiles. Open connections will be\n";
+print "logged to temporary logfiles for the next "
+ . $apacheGracefulTime / 60
+ . " minutes.\n ";
system($apacheGracefulCommand);
-print
-"Now lets hold the script for $apacheGracefulTime seconds to give apache a chance \n";
-print "to close open connections. Please stand by...\n";
+print "Now lets hold the script for "
+ . $apacheGracefulTime / 60
+ . " minutes to give the webserver a chance \n";
+print "to close open connections. Please stand by...";
sleep($apacheGracefulTime);
print "OK. It\'s time to work!\n";
processAllServers("moveLogsForParse");
-print "Now we generate the reports\n";
+print "\nNow we generate the reports\n";
processAllServers("generateReports");
+print "\nDone!\n\n";
sub processAllServers {
my $whatCanIDoForYou = shift;
@@ -112,33 +140,72 @@
$domainVhosts = $vhosts->{$domain};
for $vhost ( keys %$domainVhosts ) {
$servername = $domainVhosts->{$vhost}{'servername'};
- &{$whatCanIDoForYou};
+ if ( lc( $domainVhosts->{$vhost}{'ispmanVhostStats'} ) eq "enable"
+ || $domainVhosts->{$vhost}{'logdir'} eq "" )
+ {
+ &{$whatCanIDoForYou};
+ }
}
}
}
sub moveLogsForClose {
- my $logfile = "$logsDir/vhosts/$servername\.access";
- my $closelogfile = "$logsDir/vhosts/$servername\.access\.close";
- print "LogFile: $logfile: $logfile\n";
+ my $logdir = $domainVhosts->{$vhost}{'logdir'};
+
+ ### Here for upgraders
+ if ( $logdir eq "" ) {
+ $logdir = $ispman->getConf("apacheLogsDirectory");
+ $logdir = join "/", ( $logdir, "vhosts" );
+ }
+
+ ### Check for relative paths
+ if ( $logdir !~ /^\// ) {
+ $logdir = join "/",
+ ( $domainVhosts->{$vhost}{'serverroot'}, "vhosts", $logdir );
+ }
+
+ my $logfile = join "/", ( $logdir, $servername . ".access" );
+ my $closelogfile = join "/", ( $logdir, $servername . ".access.close" );
+ print " Working on logs for $servername...";
if ( -e $logfile ) {
- print "Working on $servername\n";
- print "Log file found\n";
- print "Moving $logfile to $closelogfile now\n";
+ print " (found)...";
+ print " (moved)\n";
move( $logfile, $closelogfile );
}
}
sub moveLogsForParse {
- print "Working on $servername\n";
- my $logfile = "$logsDir/vhosts/$servername\.access\.close";
- my $rawfile = "$servername\.access";
- print "Logfile: $logfile\n";
+ my $statdir = $domainVhosts->{$vhost}{'statdir'};
+ my $logdir = $domainVhosts->{$vhost}{'logdir'};
+
+ ### Here for upgraders
+ if ( $logdir eq "" ) {
+ $logdir = $ispman->getConf("apacheLogsDirectory");
+ $logdir = join "/", ( $logdir, "vhosts" );
+ }
+ if ( $statdir eq "" ) {
+ $statdir = $ispman->getConf("apacheLogsDirectory");
+ $statdir = join "/", ( $statdir, "domains", $domain, $vhost );
+ }
+
+ ### Check for relative paths
+ if ( $logdir !~ /^\// ) {
+ $logdir = join "/",
+ ( $domainVhosts->{$vhost}{'serverroot'}, "vhosts", $logdir );
+ }
+ if ( $statdir !~ /^\// ) {
+ $statdir = join "/",
+ ( $domainVhosts->{$vhost}{'serverroot'}, "vhosts", $statdir );
+ }
+
+ my $logfile = $logdir . "/" . $servername . ".access.close";
+ my $rawfile = $servername . ".access";
+ print " Logfile for $servername...";
if ( -e $logfile ) {
- print "Log file found\n";
- my $rawDirectory = "$logsDir/domains/$domain/$vhost/raw";
- my $reportDirectory = "$logsDir/domains/$domain/$vhost/report";
+ print "(found)\n";
+ my $rawDirectory = $statdir . "/raw";
+ my $reportDirectory = $statdir . "/report";
mkpath($rawDirectory) unless ( -d $rawDirectory );
mkpath($reportDirectory) unless ( -d $reportDirectory );
move( $logfile, "$rawDirectory/$rawfile" );
@@ -146,14 +213,28 @@
else {
print "No logfile found. Skipping this one\n";
}
- print "\n";
}
sub generateReports {
- my $logfile = "$logsDir/domains/$domain/$vhost/raw/$servername\.access";
+ my $statdir = $domainVhosts->{$vhost}{'statdir'};
+ my $logfile, $vhostDirectory, $rawDirectory;
+
+ ### Here for upgraders
+ if ( $statdir eq "" ) {
+ $statdir = $ispman->getConf("apacheLogsDirectory");
+ $statdir = join "/", ( $statdir, "domains", $domain, $vhost );
+ }
+
+ ### Check for relative paths
+ if ( $statdir !~ /^\// ) {
+ $statdir = join "/",
+ ( $domainVhosts->{$vhost}{'serverroot'}, "vhosts", $statdir );
+ }
+
+ $vhostDirectory = $statdir;
+ $logfile = $vhostDirectory . "/raw/" . $servername . ".access";
if ( -e $logfile ) {
- $vhostDirectory = "$logsDir/domains/$domain/$vhost";
- $rawDirectory = "$logsDir/domains/$domain/$vhost/raw";
+ $rawDirectory = "$vhostDirectory/raw";
open "FILE", "$logfile" || die "Cant open logFile";
$lastDate = "";
@@ -172,7 +253,7 @@
# generateHtAccessFile();
if ( -e $webalizer ) {
- print "Making report for $servername\n";
+ print " Building report for $servername\n";
my $cmd =
"perl $FindBin::Bin/ispman.loganalyzer -c $webalizer -d $vhostDirectory";
system($cmd);
-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND