diff --git a/plugins/dynamix/SyslogSettings.page b/plugins/dynamix/SyslogSettings.page new file mode 100644 index 000000000..0af7f28b3 --- /dev/null +++ b/plugins/dynamix/SyslogSettings.page @@ -0,0 +1,90 @@ +Menu="NetworkServices" +Title="Syslog Server" +Icon="file-text-o" +Tag="file-text-o" +--- + + + + + +
+ + + +Local syslog server: +: + + + +> Let the server act as a central syslog server and collect syslog messages from other systems. +> The server can listen on UDP, TCP or both with a selectable port number. +> +> Syslog information is stored per IP address. That is every system gets its own syslog file. + + + +Remote syslog server: +: + + + +> Enter a name or IP address of a remote syslog server. +> This will send a copy of the syslog messages to the designated server. + +Mirror syslog to flash: +: + +> This setting is OFF by default and must be used with care to avoid unnecessary wear and tear of the USB device. +> +> Change this setting to YES when troubleshooting is required and it is not possible to get the regular diagnostics information. +> A mirror of the syslog file is stored in the **logs** folder of the flash device. + +  +: +
\ No newline at end of file diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config new file mode 100644 index 000000000..ed0acffcf --- /dev/null +++ b/plugins/dynamix/scripts/rsyslog_config @@ -0,0 +1,57 @@ +#!/bin/bash + +CONF=/boot/config/rsyslog.conf +ETC=/etc/rsyslog.conf + +# read settings +source /boot/config/rsyslog.cfg + +# create local ruleset +if ! grep -q '^\$RuleSet local$' $ETC; then + sed -ri '/^# limetech - everything goes to syslog.$/a $RuleSet local' $ETC + sed -ri '/^#?news.notice.*$/a $DefaultRuleset local' $ETC +fi + +# local syslog server +if [[ -n $local_server ]]; then + if [[ $server_protocol == tcp || $server_protocol == both ]]; then + sed -ri "s/^#?(\\\$ModLoad imtcp)/\1/;s/^#?(\\\$InputTCPServerRun) [0-9]+/\1 ${server_port:-514}/" $ETC + [[ $server_protocol == tcp ]] && sed -ri 's/^\$(ModLoad imudp|UDPServerRun)/#\$\1/' $ETC + fi + if [[ $server_protocol == udp || $server_protocol == both ]]; then + sed -ri "s/^#?(\\\$ModLoad imudp)/\1/;s/^#?(\\\$UDPServerRun) [0-9]+/\1 ${server_port:-514}/" $ETC + [[ $server_protocol == udp ]] && sed -ri 's/^\$(ModLoad imtcp|InputTCPServerRun)/#\$\1/' $ETC + fi + if grep -q '^\$template remote,' $ETC; then + sed -ri '/^\$RuleSet remote$/d;/^\*\.\* \?remote$/d;/^\$template remote,".*"$/d' $ETC + fi + sed -ri "/^#?\\\$UDPServerRun [0-9]+.*$/a \\\$template remote,\"${server_folder:-/mnt/user/system}/syslog-%FROMHOST-IP%\"" $ETC + sed -ri '/^# #+ Remote Logging/i $RuleSet remote\n*.* ?remote' $ETC +else + sed -ri 's/^#?\$(ModLoad imtcp|InputTCPServerRun|ModLoad imudp|UDPServerRun)/#\$\1/' $ETC + sed -ri '/^\$RuleSet remote$/d;/^\*\.\* \?remote$/d;/^\$template remote,".*"$/d' $ETC +fi + +# remote syslog server +if [[ -n $remote_server ]]; then + [[ $remote_protocol == udp ]] && com='@' || com='@@' + sed -ri "s/^#?(\*\.\*) @@?.*:[0-9]+$/\1 $com$remote_server:${remote_port:-514}/" $ETC +else + sed -ri 's/^#?(\*\.\* @@?.*:[0-9]+)$/#\1/' $ETC +fi + +# mirror syslog to flash +if [[ -n $syslog_flash ]]; then + if ! grep -q '^\$template flash,' $ETC; then + sed -ri '/^#?\$UDPServerRun [0-9]+.*$/a $template flash,"/boot/logs/syslog"' $ETC + sed -ri '/^\*\.debug .*syslog$/a *.debug ?flash' $ETC + fi +else + sed -ri '/^\$template flash,"\/boot\/logs\/syslog"$/d;/^\*\.debug \?flash/d' $ETC +fi + +# copy conf to flash (read settings on reboot) +cp -f $ETC $CONF + +# update syslog daemon +/etc/rc.d/rc.rsyslogd restart &> /dev/null