hello,
I am trying to parse, format and mail some log files on a server. I was using shell scripts to parse the different log files and mail them out. However, the network has grown and as a result the log files are massive. And as a result of the larger log files, the shell scripts aren't cutting it. This brings me to my current issue.
I have never used Perl to write anything. I just started playing around with this idea this afternoon and have hit a wall and need some help. What i have so far:
#!/usr/bin/perl
#
use warnings;
open(LOG,"cmtslogs") or die "Unable to open logfile:$!\n";
while(<LOG>) {
if(($_ =~ /up/) || ($_ =~ /down/))
{
print ($_);
$last_line = $_;
}
}
close(LOG);
This works well but isn't anywhere near what i want. I would like to set it up so it ignores multiple lines of the same log and instead prints out the number of times the line repeated. In addition, it should ignore certain parts of the log line. Here is an example of one of the log lines:
Dec 14 17:39:34 <RFC1918> 1864244: SLOT 8/1: Dec 14 17:40:33: %UBR10000-5-UNREGSIDTIMEOUT: CMTS deleted unregistered Cable Modem <MAC000.0000.0000>
I would like to print out the dates, times, device name and the actual log message.