Stellarcore.net
Search: Google
Whois
 Links of the Moment: Nekochan  Apple Computers

This script is used to generate Analog logfiles for multiple Vhosts. The logic is each vhost has a configuration file in a target directory, for every .cfg file a log will be read and output will be generated by analog.

#!/usr/bin/perl

#My Analog Cron job
#Written by Mike Tremaine mgt-@@-stellarcore.net 08/09/00
#Create website.com.cfg files in the $CONF_DIR
#Currently will run once a week and generate weekly report

use strict;
use File::Copy;

my $CONF_DIR = "/etc/analog_conf";
my $LOG_DIR = "/var/log/httpd";
my $Today = `date +%Y-%m-%d`;

chomp $Today;

opendir(DIR, "$CONF_DIR") || die "Can not open DIR  $!";
my @dir_data = (grep(/\.cfg$/, readdir(DIR)));
closedir(DIR) || die "Can not close DIR  $!";

for my $targets (@dir_data) {

my $infile = "$CONF_DIR/$targets";
`/usr/bin/analog -G +g$infile +F-00-00-07 +T-00-00-00`;

my $log_file = $targets;
$log_file =~ s/.cfg$/-access_logs/;

copy ("$LOG_DIR/$log_file", "$LOG_DIR/Archives/$log_file-$Today") || die "Can't copy $log_file $!\n";

open (NEWFILE, ">$LOG_DIR/$log_file") || die "Can't open $log_file $!\n";
close (NEWFILE);

}

exit;
A smample CONF file