I've only done limited Cisco log parsing, but since the format is very cnsistent up until the %Whatever, why not start with a split(' ') and then parse the pieces, ala:

# untested while (<>) { my ($mon, $day, $time, $rtr, $seqno, $rmon, $rday, $rtime, $rtz, $c +ode, $msg) = split(' ', $_, 11); next unless $code =~ m!\%SEC-6-IPACCESSLOGP:|\%SEC-6-IPACCESSLOGDP: +!: # process stuff here, ala: my (undef, $listno, $act, $proto, $src, undef, $trget, $other, $cnt +, ) = split(' ', $msg); }
Now the parts that are consistent are split out. You'll still have to deal with the message-type dependent stuff - which should be in $msg - there's no help for that, but now you can attack the individual pieces wihout hurting your brain so badly.

And if all the messages that you're interested in are ACL violations, you can let split break all the pieces out for you.

(And anyhow, aren't you really looking for "-> IP_addr(69)", at least this week? I know I was on Friday - ALL day.)

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.


In reply to Re: CISCO Log file pattern matching (again!) by bobn
in thread CISCO Log file pattern matching (again!) by blue_cowdawg

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.