#!/usr/bin/perl -w ###### Configuration ######################################################### my %defaults = ( # default values for command-line options 'h' => 0, # Show help then exit 'V' => 0, # Show version then exit 'v' => 0, # Verbosity level - see docs for details 'e' => '1w', # expiry time 'r' => '300s', # timed-out request retry delay 'a' => '0.5h', # failed lookup retry delay 't' => '60s', # Lookup timeout 'c' => 32, # Number of children 'q' => 4096, # Maximum queue length per stream 'w' => 512, # sort window size 'x' => 64, # sort window dump chunk 'd' => '/tmp/logresolve.cache', # DB cache file # 'D' => '/tmp/logresolve.debug', # Debug out - STDERR if undef 'i' => '-', # input file 'o' => '-', # output file 'b' => undef, # Total bytecount file 's' => undef, # IP stats file 'f' => undef, # I/O mapping file 'm' => undef, # I/O mapping list ); my %extensions = ( # how to compress/uncompress various compression formats # extension compress command uncompress command 'Z' => [ 'compress -c', 'uncompress -c' ], 'gz' => [ 'gzip -9 -', 'gunzip -' ], 'bz2' => [ 'bzip2 -9 -', 'bunzip2 -' ], ); ###### Documentation ######################################################### =head1 NAME logresolve.pl - log file reverse nameservice resolver =head1 SYNOPSIS logresolve.pl [B<-h>] [B<-V>] [B<-v>] S<[B<-e> time]> S<[B<-r> time]> S<[B<-a> time]> S<[B<-t> time]> S<[B<-c> #]> S<[B<-q> #]> S<[B<-w> #]> S<[B<-x> #]> S<[B<-d> file]> S<[B<-i> file]> S<[B<-o> file]> S<[B<-b> file]> S<[B<-s> [file]]> S<[B<-f> file]> S<[B<-m> input,output,[bytecount],[stats] ...]> =head1 DESCRIPTION I performs reverse nameservice lookups on long lists of IP addresses. Its primary intent and most common use is to resolve IP addresses recorded in HTTP daemon log files to their more human-readable domain names. This typically makes the statistics generated from such log files much more useful. Most HTTP daemons do have the capability of performing reverse nameservice on the fly, and some will cache the results so that subsequent lookups are instantaneous. However, very few do it B, so the initial request from any given IP number is delayed slightly while the server waits for the reverse lookup to complete. Thus, turning off reverse lookups can increase performance, especially on highly loaded web servers. I allows server administrators to reduce the load on their servers by deferring these reverse lookups to a more convenient time, network, or machine. I can cache the results of its lookups in a local database file so that multiple runs of I can share reverse lookup information. This minimizes the impact of logresolve on your local nameserver. I can be configured to cache these results for longer than the expiry date on the DNS record. Because few reverse nameservice records change very often, this can give increased performance with minimal degradation in the accuracy of results. =head1 OPTIONS The defaults for all options can be set in the B section, found at the top of B. Any B option can be specified as a filename or B<-> for STDIN/STDOUT, or B<=> for STDERR (where applicable). Any B