Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
My question is this, Currently the out put is only ip numbers. I want to add another part to the script that shows the connections by their dns name. How would i go about doin this. I was thinkin it would be another foreach loop and doing an nslookup( i dont know the perl code for that) on each element. Any help or suggestions would be greatly appreciated. thanks, a perl newbie#!/usr/local/bin/perl # # ACLlogscan.pl -- a script to summarise ACL log files # # Set behaviour $log="H:/sys075/acls/local7.log"; # absolute path of ACL log file $ntop=40; # shows the top ten results(number can be cha +nged i.e.if # the number # is changed to 20 then you would see the top 20 r +esults) chomp ($acl=$ARGV[0]); # User can enter a specific acl numb +er if ($acl == "") { $acl=".*"}; # if nothing is entered then open(LOG , "<$log") or die; # open the log file stated in the b +ehaviour set while (<LOG>) { if (/IPACCESSLOGP: list $acl denied ([tcpudim]+) ([0-9.]+)\(([0-9]+)\ +) -> ([0-9.]+)\(([0-9]+)\), ([0-9]+) /) { # pattern ma +tching line $x=$6; $srca{$2}+=$x; $foo=sprintf("%16s -> %16s %3s port %-6s",$2,$4,$1,$5); $moo=sprintf("%3s port %-6s",$1,$5); $quad{$foo}+=$x; $port{$moo}+=$x; } } $n=0; printf ("Connection Summary:\n"); foreach $i (sort { $quad{$b} <=> $quad{$a} } keys %quad) { if ($n++ >= $ntop) { last }; printf ("%6s:%s\n", $quad{$i},$i); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Adding an nslookup to a log script
by ikegami (Patriarch) on Dec 20, 2004 at 17:02 UTC | |
|
Re: Adding an nslookup to a log script
by NetWallah (Canon) on Dec 20, 2004 at 16:59 UTC | |
|
Re: Adding an nslookup to a log script
by borisz (Canon) on Dec 20, 2004 at 17:06 UTC | |
|
Re: Adding an nslookup to a log script
by bgreenlee (Friar) on Dec 20, 2004 at 17:04 UTC | |
|
Re: Adding an nslookup to a log script
by Fletch (Bishop) on Dec 20, 2004 at 18:33 UTC | |
|
Re: Adding an nslookup to a log script
by Random_Walk (Prior) on Dec 20, 2004 at 17:15 UTC |