Yesterday, while running logcheck against all my syslogs for the week, I
started bemoaning how long the whole thing was taking (over 9 minutes
for 4 megs). I wondered if maybe one bad regex was stalling the whole
thing, but the debug output showed that all rulefiles were taking up
time proportional to their size. (Besides, egrep being based on a DFA,
it doesn't care much about how a regex is written.)
Out of curiosity, and realizing that an egrep regex should, AFAIK, work
just the same in Perl, I whipped up a one-liner to test out one
rulefile. egrep took over 20 seconds to match ignore.d.server/spamd
against my logs; perl took less than 2 to produce the same results.
So, I wrote up the attached script as a quick hack to try out perl as a
substitute for egrep. This brought the run time down to less than a
minute and a half. As Mr. Brian Norris said: "I'm convinced". :)
Now, I'm not advocating immediate action, as such a switch should
certainly not be taken lightly, especially given the security role of
logcheck. Nevertheless, I think it's something worth mulling over,
given the speed difference. What do you think?