#!/usr/bin/perl -w use diagnostics; #This file parses out squids access log for address bar entries to see where users purposefully go $date=`date`; $net="192.168.4."; $counter=10; $logpath="/var/log/squid/userarchive/"; $ip=$net.$counter; #The counter is set to the max ipadress +1 while ( $counter <= 14 ) { #Print the date to each file we're writing to open(LOGF,">>",$logpath . $ip); print LOGF "$date\n"; $|++; close LOGF; #Grab the access log and go through it, splitting each line into elements of the array open(INFILE,"/var/log/squid/access.log") or die "Can’t open /var/log/squid/access.log: $!"; while ( ) { @array = split(" ",); $ip=$net.$counter; #Only grab things associated with the current searched for ip and ends with .com .net and so on if (($array[7] =~ /[com|org|net|gov|cc|mil]\/$/)&&($array[3] eq $ip)) { #Write it to the log file open(LOGF,">>",$logpath . $ip) or die "Can't open $logpath$ip: $!"; print LOGF "$ip \: $array[0] $array[7]\n"; close LOGF; } } $counter++; }