-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogrss.pl
31 lines (18 loc) · 813 Bytes
/
logrss.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl -w
use lib '/home/ben/web/lib/perl';
use strict;
use Date::Manip;
my $yesterdays_date = &UnixDate("yesterday","%Y%m%d");
my $logfile_file = "/web/logs/ben/benhammersley.com/$yesterdays_date.log";
open (LOGFILE, "< $logfile_file");
while (<LOGFILE>) { my ($host, $ident_user, $auth_user, $date, $time, $time_zone, $method, $url, $protocol, $status, $bytes, $referer, $agent) = /^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] "(\S+) (.+?) (\S+)" (\S+) (\S+) "([^"]+)" "([^"]+)"$/;
my $cleaned_status = $status || "111";
if ($cleaned_status == "404") {
$rss -> add_item(title => "$url",
link => "$url",
description => "$referer");
}
}
close (LOGFILE);
print header('application/xml+rss');
print $rss->as_string;