<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/afs/athena/contrib/perl/p

while($ARGV[0] =~ /^\-/){
    $arg = shift(@ARGV);
    if($arg eq "-whois"){
	$whoisfeature = 1;
    }
    elsif($arg eq "-wic"){
	$wicfeature = 1;
	print("WIC feature on\n");
    }
    elsif($arg eq "-rr"){
	$regreports=1;
    }
    elsif($arg eq "-wicr"){
	$wicreport = 1;
	print("WIC reporting on\n");
    }
}

$| = 1;
#$SIG{'INT'} = 'report';
while(&lt;&gt;){
    next if /graphics/;
#    print("***$_\n");
    ($host, $wday, $mon, $day, $time, $year, $method, $path)= split;
    (@hparts) = split(/\./, $host);
    (@pparts) =  split(/\//, $path);
    $fld = $hparts[$#hparts-1].".".$hparts[$#hparts];
    $fld = "Unresolved" if $host!~/[A-Za-z]/;

######### Whois block    
    if($whoisfeature){
	if($host =~ /[a-zA-Z]/){
	    $whois{$fld} = &amp;whois_lookup($fld) unless $whois{$fld};
	}
	else{
	    if($hparts[0] &lt; 127){
		$fld = "net $hparts[0]";
	    }			# 
	    elsif($hparts[0] &lt; 191){
		$fld = "net $hparts[0]".".".$hparts[1];
	    }
	    else{
		$fld = "net ".$hparts[0].".".$hparts[1].".".$hparts[2];
	    }
	    $whois{$fld} = &amp;whois_lookup($fld) unless $whois{$fld};
	}
    }
######### End Whois Block
    
    $hostc{$fld}++;
    $count++;

######### WIC block
    if($wicfeature){
#	print("Is it wic?: \"$pparts[1]\"\n");
	if($pparts[1] eq "wic"){
	    $wicdocs{$path}++;
	    ########## WIC report block
	    if($wicreport){
#		print("$path: $wicdocs{$path}\n");
		if(($wicdocs{$path}/100) == int($wicdocs{$path}/100) &amp;&amp;
		   $wicdocs{$path} &gt; $highest){
		    &amp;wicreport;
		}
	    }
	    ######### End WIC report block
	}
    }
######### End WIC block

######### Regreports block
    if($regreports == 1){
	if($count==25){
	    &amp;report2;
	    $count = 0;
	}
    }
######### End Regreports block


}

&amp;report2;
&amp;wicreport if $wicfeature;

sub wicreport {
    print("WICReporting...................................................\n");
    @topdocs = sort {$wicdocs{$b} &lt;=&gt; $wicdocs{$a}} keys %wicdocs;
    $highest = $wicdocs{$topdocs[0]};
    for $doc (@topdocs){
	print(&amp;pad($doc, 40), ": ", $wicdocs{$doc}, "\n") 
	    if $wicdocs{$doc} &gt; ($highest/25);
    }
    print("...............................................................\n");

}

sub report2 {
    print("Reporting......................................................\n");
    @topdoms = sort {$hostc{$b} &lt;=&gt; $hostc{$a}} keys %hostc;
    for $dom (@topdoms){
	print(&amp;pad($dom, 20), ": ", &amp;pad($hostc{$dom}, 5), 
	      "  [", $whois{$dom}, "]\n");
    }
    print("...............................................................\n");
}

sub pad {
    local($string, $len) = @_;
    local($padding);

    $padding = " " x ($len-length($string));
    $string.$padding;
}

sub whois_lookup {
    local($domain) = @_;

    print("Looking up $domain\n");
    open(WH, "whois -h internic.net \"$domain\"|");
    while(&lt;WH&gt;){
	if(/([^\(]+) \([A-Z\-]+\)/){
	    print("New connection from \"$1\"\n");
	    return $1;
	}
	if(/No match for/){
	    print("Unknown FLD $domain\n");
	    return "Unknown";
	}
	if(/system load/){
	    return "";
	}
    }
    close(WH);
}
</pre></body></html>