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 30 31 32 33 34 35 36 37 38
|
#! /usr/bin/perl -w
# fixscript will replace this line with code to load INN::Config
# Keep track of which groups are currently being read. Takes logfile input
# on stdin.
$readfile="$INN::Config::newsetc/readgroups";
$curtime = time;
$oldtime = $curtime - 30 * 86400; # 30 days in the past
if (open(RDF, $readfile)) {
while (<RDF>) {
chop;
@foo=split(/ /); # foo[0] should be group, foo[1] lastreadtime
if ($foo[1] < $oldtime) {
next; # skip entries that are too old.
}
$groups{$foo[0]} = $foo[1];
}
close(RDF);
}
# read input logs.
while (<>) {
next unless /nnrpd/;
next unless / group /;
chop;
@foo = split(/ +/);
# group name is in the 8th field.
$groups{$foo[7]} = $curtime;
}
open(WRF, ">$readfile") || die "cannot open $readfile for write.\n";
foreach $i (keys %groups) {
print WRF $i, " ", $groups{$i}, "\n";
}
exit(0);
|