#!/usr/bin/perl -w # # Reads a syslog-format log file and provides an RSS entry for each valid line. # # Copyright 2005 codepoet (codepoet@codepoetry.net) # # This software is released without warranty of any kind and may be redistributed or modified as long as this copyright and license are attached. # use strict; my @months = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); my $filename = shift @ARGV; my $cap = shift @ARGV || 0; if (!$filename) { print < $filename file://$filename END ; my @file = ; for (my $ln = (@file - $cap); @file > $ln; $ln++) { $line = $file[$ln]; $line =~ s/[^[:print:]]//g; my ($month, $day, $time, $host, $msg) = $line =~ /^(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*)$/; my $monthnum = grep(@months, $month); my $timecode = sprintf("%d-%02d-%02dT%s-06:00",$year,$monthnum,$day,$time); if ($msg) { print < <![CDATA[$msg]]> file://$filename $ln\@$timecode $timecode END ; } } print < END ; close (LOG); } else { print STDERR "$filename does not exist."; }