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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |