Dear enlightened ones I have a code that summarises log files and returns a summary with the relevant ip addresses and their frequency. The code looks like this:
#!/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); }
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

In reply to Adding an nslookup to a log script by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.