Syslog compatible output from socklog
Lars Kellogg-Stedman <[email protected]>
| Newsgroups | gmane.comp.misc.pape.general |
|---|---|
| Message-ID | <[email protected]> |
I'd like to replace the stock syslog in our environment with socklog, but
we're using a variety of reporting tools -- many developed elsewhere -- to
perform logfile analysis, and they choke on the socklog format logfiles.
Rather than rewriting more software than I care to think about, I'd rather
see syslog-compatible output from socklog. While I may tackle a patch to
socklog itself sometime in the future, for the time being I've inserted a
small perl shim into the pipeline to convert socklog's output into syslog.
I'm including it here on the odd change that it will save somebody else 15
minutes or so:
#!/usr/bin/perl -w
use strict;
our $hostname;
BEGIN {
open unameHANDLE, "uname -n |";
chomp($hostname = <unameHANDLE>);
close unameHANDLE;
}
# Autoflush output.
$|=1;
while (<>) {
s{
\w+\.\w+ : \s+ # facility.priority
(\w{3} \s+ \d+ \s+ [\d:]+) \s+ # date and time
(.*) # everything else
}{$1 $hostname $2}x;
print;
}
This makes, for example, /etc/socklog/unix/log/run look like:
#!/bin/sh
chpst -unobody /bin/sock2sys | chpst -usys svlogd \
main/main main/auth main/cron main/daemon main/debug main/ftp \
main/kern main/local main/mail main/news main/syslog main/user
If someone has a better solution, I'd love to hear it.
Ciao,
-- Lars
--
Lars Kellogg-Stedman <[email protected]>