Last active
January 25, 2025 07:06
-
-
Save mhofman/79e9d1bc175deb7d90143a8946f25fbf to your computer and use it in GitHub Desktop.
syslog-ng on AsusWRT Merlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
alias log="logger -p user.info -t services-start" | |
RC='/opt/etc/init.d/rc.unslung' | |
i=30 | |
until [ -x "$RC" ] ; do | |
i=$(($i-1)) | |
if [ "$i" -lt 1 ] ; then | |
log Could not start Entware | |
exit | |
fi | |
sleep 1 | |
done | |
$RC start | |
i=30 | |
until [ -p "/tmp/syslog-ng-pipe" ] ; do | |
i=$(($i-1)) | |
if [ "$i" -lt 1 ] ; then | |
log "Could not send startup log to syslog-ng" | |
exit | |
fi | |
sleep 1 | |
done | |
cat /tmp/syslog.log > /tmp/syslog-ng-pipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@version:3.9 | |
options { | |
chain_hostnames(no); | |
create_dirs(yes); | |
flush_lines(0); | |
keep_hostname(yes); | |
log_fifo_size(4096); | |
stats_freq(0); | |
flush_lines(0); | |
use_dns(yes); | |
use_fqdn(no); | |
dns-cache-hosts(/etc/hosts.dnsmasq); | |
}; | |
filter bad_program { | |
not match(": $" value("MSGHDR")) and match("^([^:]*): *((?:.|\n)*)$" flags(store-matches) value("MESSAGE")); | |
}; | |
rewrite rewrite_program { | |
subst(' ', '_', value("1"), flags(global)); | |
set("${PROGRAM}_$1", value("PROGRAM")); | |
set("$2", value("MESSAGE")); | |
}; | |
source net { | |
network( | |
ip("192.168.0.1") | |
transport("udp") | |
port(514) | |
flags(no-hostname) | |
); | |
}; | |
source named_pipe { | |
pipe("/tmp/syslog-ng-pipe"); | |
}; | |
source fixed_net_and_pipe { | |
channel { | |
source(net); | |
source(named_pipe); | |
junction { | |
channel { filter(bad_program); rewrite(rewrite_program); flags(final);}; | |
channel { }; | |
}; | |
}; | |
}; | |
destination messages { | |
file("/mnt/usb/logs/${HOST_FROM}/${C_YEAR}-${C_MONTH}.log" flags(syslog-protocol)); | |
}; | |
destination log_server { | |
syslog("192.168.0.2" | |
transport("tcp") | |
port(601) | |
); | |
}; | |
log { | |
source { internal(); }; | |
source(fixed_net_and_pipe); | |
destination(messages); | |
destination(log_server); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For context, see https://www.snbforums.com/threads/configuring-syslog-ng-with-merlin-firmware.35095/page-2#post-335232