First off, i know very very little perl, which is why i'm here. First time posting, but i've used this as a reference page for awhile.

So i have a script that needs to parse out a comma delimited syslog file based on error messages i have in a seperate file. Now i have one last thing to do to get this thing over with. After a downtime i need to search for a corresponding uptime message and append the uptime date and time to the end of what the script parses out. Something to keep in mind, the uptime may come after the script goes through the syslog. right now each time the script runs(every 15 minutes) it parses out the data, sends the output to a server, and clears the syslog. So i am going to have to have a way to keep a entry in memory, or a seperate file, until the uptime message gets logged.

Examples and current script:
The syslog is formatted identical to the current output, it has no uptime information conatined on the same line.

Current output:
server name, date, time, error message, error type(waning, error, notice)

What i need:
server name, date, time, error message, error type(waning, error, notice), uptime date, uptime time

Current script:

$logdir= "d:/logs/"; $logfile= "sysmonitor.log"; $errlst= "errorlist.txt"; &FltErr; sub FltErr { open (FH, "< $errlst"); my @errors = <FH>; chdir($logdir); open (msg, $logfile ); open (FILEHANDLE,">NTDTM.txt"); while (<msg> ) { chop($_); foreach my $error (@errors) { chomp ($error); if ($_ =~ $error) { print FILEHANDLE "$_ \n"; print "$_ \n"; } } } close (FILEHANDLE); } &Mail; sub Mail { `blat NTDTM.txt -t user\@email.com -f user\@email.com -s "Windows DTM +logs"`;

Any help is GREATLY appreciated.


In reply to comma delimited, syslog parsing by jeff061

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.