#!/usr/bin/perl -w use strict; use Sys::Hostname; $|++; # Where should the logs go? my $outputdir = '/tmp/sitelog'; # Exit if the directory already exists, otherwise create it. if ( -d $outputdir ) { die "$outputdir already exists, exiting!\n"; } else { mkdir $outputdir; } # Use just the WS hostname, not FQDN my $hostname = hostname; $hostname =~ s/\..+$//; # Cache of site FDs my %fd_repo = (); while(<>) { my($client, $site) = (split)[0,5]; # skip the bigip lookups next if ($client =~ /^65\.214\.43\.13[01]/); unless (exists $fd_repo{$site}) { mkdir "$outputdir/$site"; open($fd_repo{$site}, ">$outputdir/$site/$hostname") || die "Can't write log for $site: $!\n"; } print { $fd_repo{$site} } $_; }