From 384f50d97770cc839e3814736c8e85696ef41cdc Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 4 Feb 2019 21:30:26 +0100 Subject: [PATCH 01/19] Added syslog server functionality --- plugins/dynamix/SyslogSettings.page | 90 ++++++++++++++++++++++++++ plugins/dynamix/scripts/rsyslog_config | 57 ++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 plugins/dynamix/SyslogSettings.page create mode 100644 plugins/dynamix/scripts/rsyslog_config 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 From cdd4b459ab21e516bd752d90153261fc9a904259 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 4 Feb 2019 21:41:17 +0100 Subject: [PATCH 02/19] Changing file permissions --- plugins/dynamix/scripts/rsyslog_config | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 plugins/dynamix/scripts/rsyslog_config diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config old mode 100644 new mode 100755 From 19b058c63e878cde702b21b4279e24918985c073 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 4 Feb 2019 21:54:40 +0100 Subject: [PATCH 03/19] syslog icon update --- plugins/dynamix/SyslogSettings.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/SyslogSettings.page b/plugins/dynamix/SyslogSettings.page index 0af7f28b3..0e08a8366 100644 --- a/plugins/dynamix/SyslogSettings.page +++ b/plugins/dynamix/SyslogSettings.page @@ -1,6 +1,6 @@ Menu="NetworkServices" Title="Syslog Server" -Icon="file-text-o" +Icon="icon-eula" Tag="file-text-o" --- Date: Tue, 5 Feb 2019 00:04:39 +0100 Subject: [PATCH 04/19] syslog script corrections --- plugins/dynamix/scripts/rsyslog_config | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config index ed0acffcf..17013925e 100755 --- a/plugins/dynamix/scripts/rsyslog_config +++ b/plugins/dynamix/scripts/rsyslog_config @@ -8,28 +8,28 @@ 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 + sed -ri '/^# limetech - everything goes to syslog.$/a$RuleSet local' $ETC + sed -ri '/^#?\*\.\* @@?.*:[0-9]+$/a$DefaultRuleset local' $ETC fi # local syslog server if [[ -n $local_server ]]; then + if ! grep -q '^\$RuleSet remote$' $ETC; then + sed -ri '$a\$RuleSet remote\n*.* ?remote' $ETC + fi 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 + sed -ri '/^\$InputTCPServerBindRuleset remote$/d;/^\$InputTCPServerRun [0-9]+$/d;s/^#?(\$ModLoad imtcp)/\1/' $ETC + sed -ri "\$a\\\$InputTCPServerBindRuleset remote\n\\\$InputTCPServerRun ${server_port:-514}" $ETC + [[ $server_protocol == tcp ]] && sed -ri 's/^(\$ModLoad imudp)/#\1/;/^\$InputUDPServerBindRuleset remote$/d;/^\$UDPServerRun [0-9]+$/d' $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 + sed -ri '/^\$InputUDPServerBindRuleset remote$/d;/^\$UDPServerRun [0-9]+$/d;s/^#?(\$ModLoad imudp)/\1/' $ETC + sed -ri "\$a\\\$InputUDPServerBindRuleset remote\n\\\$UDPServerRun ${server_port:-514}" $ETC + [[ $server_protocol == udp ]] && sed -ri 's/^(\$ModLoad imtcp)/#\1/;/^\$InputTCPServerBindRuleset remote$/d;/^\$InputTCPServerRun [0-9]+$/d' $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 + sed -ri "/^\\\$template remote,.*$/d;/^#\\\$UDPServerRun [0-9]+.*$/a\\\$template remote,\"${server_folder:-/mnt/user/system}/syslog-%FROMHOST-IP%.log\"" $ETC else - sed -ri 's/^#?\$(ModLoad imtcp|InputTCPServerRun|ModLoad imudp|UDPServerRun)/#\$\1/' $ETC - sed -ri '/^\$RuleSet remote$/d;/^\*\.\* \?remote$/d;/^\$template remote,".*"$/d' $ETC + sed -ri '/^\$RuleSet remote$/d;/^\*\.\* \?remote$/d;/^\$template remote,".*"$/d;/^\$Input(TCP|UDP)ServerBindRuleset remote$/d;/^\$(InputTCP|UDP)ServerRun [0-9]+$/d;s/^#?\$(ModLoad imtcp|ModLoad imudp)/#\$\1/' $ETC fi # remote syslog server @@ -43,8 +43,8 @@ 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 + 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 From d3ff5051db47ee97d739015ddd045585ead4dcc5 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 00:18:35 +0100 Subject: [PATCH 05/19] syslog save file on flash in DOS format --- plugins/dynamix/scripts/rsyslog_config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config index 17013925e..f5eb8fa95 100755 --- a/plugins/dynamix/scripts/rsyslog_config +++ b/plugins/dynamix/scripts/rsyslog_config @@ -51,7 +51,7 @@ else fi # copy conf to flash (read settings on reboot) -cp -f $ETC $CONF +todos <$ETC >$CONF # update syslog daemon /etc/rc.d/rc.rsyslogd restart &> /dev/null From b8489b92322d5a74a537a2ac0b40bc036d62488c Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 00:33:43 +0100 Subject: [PATCH 06/19] syslog code correction --- plugins/dynamix/scripts/rsyslog_config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config index f5eb8fa95..b718182ff 100755 --- a/plugins/dynamix/scripts/rsyslog_config +++ b/plugins/dynamix/scripts/rsyslog_config @@ -43,7 +43,7 @@ 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 '/^#\$UDPServerRun [0-9]+.*$/a$template flash,"/boot/logs/syslog"' $ETC sed -ri '/^\*\.debug .*syslog$/a*.debug ?flash' $ETC fi else From 1a07befdc6c176a55be718072a337e232142ed74 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 07:26:10 +0100 Subject: [PATCH 07/19] syslog disable local logging when array is stopped --- .../dynamix/event/disks_mounted/local_syslog_start | 2 ++ .../dynamix/event/unmounting_disks/local_syslog_stop | 2 ++ plugins/dynamix/scripts/rsyslog_config | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 plugins/dynamix/event/disks_mounted/local_syslog_start create mode 100644 plugins/dynamix/event/unmounting_disks/local_syslog_stop diff --git a/plugins/dynamix/event/disks_mounted/local_syslog_start b/plugins/dynamix/event/disks_mounted/local_syslog_start new file mode 100644 index 000000000..9219798ff --- /dev/null +++ b/plugins/dynamix/event/disks_mounted/local_syslog_start @@ -0,0 +1,2 @@ +#!/bin/bash +sed -ri 's/^#?(\*\.\* \?remote)$/\1/' /etc/rsyslog.conf diff --git a/plugins/dynamix/event/unmounting_disks/local_syslog_stop b/plugins/dynamix/event/unmounting_disks/local_syslog_stop new file mode 100644 index 000000000..ad3a87ad3 --- /dev/null +++ b/plugins/dynamix/event/unmounting_disks/local_syslog_stop @@ -0,0 +1,2 @@ +#!/bin/bash +sed -ri 's/^#?(\*\.\* \?remote)$/#\1/' /etc/rsyslog.conf diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config index b718182ff..5790b680b 100755 --- a/plugins/dynamix/scripts/rsyslog_config +++ b/plugins/dynamix/scripts/rsyslog_config @@ -6,6 +6,10 @@ ETC=/etc/rsyslog.conf # read settings source /boot/config/rsyslog.cfg +# read $var +source /var/local/emhttp/var.ini +[[ $fsState == Started ]] || h='#' + # create local ruleset if ! grep -q '^\$RuleSet local$' $ETC; then sed -ri '/^# limetech - everything goes to syslog.$/a$RuleSet local' $ETC @@ -15,8 +19,10 @@ fi # local syslog server if [[ -n $local_server ]]; then if ! grep -q '^\$RuleSet remote$' $ETC; then - sed -ri '$a\$RuleSet remote\n*.* ?remote' $ETC + sed -ri "\$a\\\$RuleSet remote\n*.* ?remote" $ETC fi + # enable/disable local logging + sed -ri "s/^#?(\*\.\* \?remote)$/$h\1/" $ETC if [[ $server_protocol == tcp || $server_protocol == both ]]; then sed -ri '/^\$InputTCPServerBindRuleset remote$/d;/^\$InputTCPServerRun [0-9]+$/d;s/^#?(\$ModLoad imtcp)/\1/' $ETC sed -ri "\$a\\\$InputTCPServerBindRuleset remote\n\\\$InputTCPServerRun ${server_port:-514}" $ETC @@ -53,5 +59,9 @@ fi # copy conf to flash (read settings on reboot) todos <$ETC >$CONF +# keep local logging disabled at startup +# disk mount and disk unmount events are used to start/stop logging +sed -ri 's/^(\*\.\* \?remote)$/#\1/' $CONF + # update syslog daemon /etc/rc.d/rc.rsyslogd restart &> /dev/null From aa0888c17ce42240581bd5b9b89220e399cea712 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 07:28:57 +0100 Subject: [PATCH 08/19] Make event scripts executable --- plugins/dynamix/event/disks_mounted/local_syslog_start | 0 plugins/dynamix/event/unmounting_disks/local_syslog_stop | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 plugins/dynamix/event/disks_mounted/local_syslog_start mode change 100644 => 100755 plugins/dynamix/event/unmounting_disks/local_syslog_stop diff --git a/plugins/dynamix/event/disks_mounted/local_syslog_start b/plugins/dynamix/event/disks_mounted/local_syslog_start old mode 100644 new mode 100755 diff --git a/plugins/dynamix/event/unmounting_disks/local_syslog_stop b/plugins/dynamix/event/unmounting_disks/local_syslog_stop old mode 100644 new mode 100755 From 292e6f1e4cfba0837fc562e4fa61601cfacfd482 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 07:31:12 +0100 Subject: [PATCH 09/19] Script code update --- plugins/dynamix/event/disks_mounted/local_syslog_start | 2 +- plugins/dynamix/event/unmounting_disks/local_syslog_stop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dynamix/event/disks_mounted/local_syslog_start b/plugins/dynamix/event/disks_mounted/local_syslog_start index 9219798ff..7b25b9c5b 100755 --- a/plugins/dynamix/event/disks_mounted/local_syslog_start +++ b/plugins/dynamix/event/disks_mounted/local_syslog_start @@ -1,2 +1,2 @@ #!/bin/bash -sed -ri 's/^#?(\*\.\* \?remote)$/\1/' /etc/rsyslog.conf +sed -ri 's/^#(\*\.\* \?remote)$/\1/' /etc/rsyslog.conf diff --git a/plugins/dynamix/event/unmounting_disks/local_syslog_stop b/plugins/dynamix/event/unmounting_disks/local_syslog_stop index ad3a87ad3..fe0f6ff29 100755 --- a/plugins/dynamix/event/unmounting_disks/local_syslog_stop +++ b/plugins/dynamix/event/unmounting_disks/local_syslog_stop @@ -1,2 +1,2 @@ #!/bin/bash -sed -ri 's/^#?(\*\.\* \?remote)$/#\1/' /etc/rsyslog.conf +sed -ri 's/^(\*\.\* \?remote)$/#\1/' /etc/rsyslog.conf From 96e75ec6a629bbf741fbb0999a2e52f7a7b8b364 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 07:36:01 +0100 Subject: [PATCH 10/19] Syslog code update --- plugins/dynamix/scripts/rsyslog_config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config index 5790b680b..65bb6dd4f 100755 --- a/plugins/dynamix/scripts/rsyslog_config +++ b/plugins/dynamix/scripts/rsyslog_config @@ -19,7 +19,7 @@ fi # local syslog server if [[ -n $local_server ]]; then if ! grep -q '^\$RuleSet remote$' $ETC; then - sed -ri "\$a\\\$RuleSet remote\n*.* ?remote" $ETC + sed -ri '$a\$RuleSet remote\n*.* ?remote' $ETC fi # enable/disable local logging sed -ri "s/^#?(\*\.\* \?remote)$/$h\1/" $ETC From 77db1de9001c8f9d7a4487ca6fe71fb7da54a3cf Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 08:03:13 +0100 Subject: [PATCH 11/19] Syslog code correction --- plugins/dynamix/scripts/rsyslog_config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/scripts/rsyslog_config b/plugins/dynamix/scripts/rsyslog_config index 65bb6dd4f..f5127da1e 100755 --- a/plugins/dynamix/scripts/rsyslog_config +++ b/plugins/dynamix/scripts/rsyslog_config @@ -61,7 +61,7 @@ todos <$ETC >$CONF # keep local logging disabled at startup # disk mount and disk unmount events are used to start/stop logging -sed -ri 's/^(\*\.\* \?remote)$/#\1/' $CONF +sed -ri 's/^(\*\.\* \?remote)/#\1/' $CONF # update syslog daemon /etc/rc.d/rc.rsyslogd restart &> /dev/null From eccfbc55113ebce775c48e43c952a0ed96a30b08 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 08:08:59 +0100 Subject: [PATCH 12/19] Event scripts code correction --- plugins/dynamix/event/disks_mounted/local_syslog_start | 1 + plugins/dynamix/event/unmounting_disks/local_syslog_stop | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/dynamix/event/disks_mounted/local_syslog_start b/plugins/dynamix/event/disks_mounted/local_syslog_start index 7b25b9c5b..5182220f8 100755 --- a/plugins/dynamix/event/disks_mounted/local_syslog_start +++ b/plugins/dynamix/event/disks_mounted/local_syslog_start @@ -1,2 +1,3 @@ #!/bin/bash sed -ri 's/^#(\*\.\* \?remote)$/\1/' /etc/rsyslog.conf +/etc/rc.d/rc.rsyslogd restart &> /dev/null diff --git a/plugins/dynamix/event/unmounting_disks/local_syslog_stop b/plugins/dynamix/event/unmounting_disks/local_syslog_stop index fe0f6ff29..a65dd42fc 100755 --- a/plugins/dynamix/event/unmounting_disks/local_syslog_stop +++ b/plugins/dynamix/event/unmounting_disks/local_syslog_stop @@ -1,2 +1,3 @@ #!/bin/bash sed -ri 's/^(\*\.\* \?remote)$/#\1/' /etc/rsyslog.conf +/etc/rc.d/rc.rsyslogd restart &> /dev/null From c323e002d5d42e0c8b25204653a625cc29f125a4 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 09:16:24 +0100 Subject: [PATCH 13/19] syslog event script made conditional execution --- plugins/dynamix/event/disks_mounted/local_syslog_start | 7 +++++-- plugins/dynamix/event/unmounting_disks/local_syslog_stop | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/dynamix/event/disks_mounted/local_syslog_start b/plugins/dynamix/event/disks_mounted/local_syslog_start index 5182220f8..999a9245d 100755 --- a/plugins/dynamix/event/disks_mounted/local_syslog_start +++ b/plugins/dynamix/event/disks_mounted/local_syslog_start @@ -1,3 +1,6 @@ #!/bin/bash -sed -ri 's/^#(\*\.\* \?remote)$/\1/' /etc/rsyslog.conf -/etc/rc.d/rc.rsyslogd restart &> /dev/null +ETC=/etc/rsyslog.conf +if grep '/^#\*\.\* \?remote$' $ETC; then + sed -ri 's/^#(\*\.\* \?remote)$/\1/' $ETC + /etc/rc.d/rc.rsyslogd restart &> /dev/null +fi diff --git a/plugins/dynamix/event/unmounting_disks/local_syslog_stop b/plugins/dynamix/event/unmounting_disks/local_syslog_stop index a65dd42fc..0e81d882a 100755 --- a/plugins/dynamix/event/unmounting_disks/local_syslog_stop +++ b/plugins/dynamix/event/unmounting_disks/local_syslog_stop @@ -1,3 +1,6 @@ #!/bin/bash -sed -ri 's/^(\*\.\* \?remote)$/#\1/' /etc/rsyslog.conf -/etc/rc.d/rc.rsyslogd restart &> /dev/null +ETC=/etc/rsyslog.conf +if grep '/^\*\.\* \?remote$' $ETC; then + sed -ri 's/^(\*\.\* \?remote)$/#\1/' $ETC + /etc/rc.d/rc.rsyslogd restart &> /dev/null +fi From 84feabb3bb08745a0ee7e3fdac94b07744c03179 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 5 Feb 2019 09:19:11 +0100 Subject: [PATCH 14/19] syslog event script made conditional execution --- plugins/dynamix/event/disks_mounted/local_syslog_start | 2 +- plugins/dynamix/event/unmounting_disks/local_syslog_stop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dynamix/event/disks_mounted/local_syslog_start b/plugins/dynamix/event/disks_mounted/local_syslog_start index 999a9245d..778833c4c 100755 --- a/plugins/dynamix/event/disks_mounted/local_syslog_start +++ b/plugins/dynamix/event/disks_mounted/local_syslog_start @@ -1,6 +1,6 @@ #!/bin/bash ETC=/etc/rsyslog.conf -if grep '/^#\*\.\* \?remote$' $ETC; then +if grep -q '/^#\*\.\* \?remote$' $ETC; then sed -ri 's/^#(\*\.\* \?remote)$/\1/' $ETC /etc/rc.d/rc.rsyslogd restart &> /dev/null fi diff --git a/plugins/dynamix/event/unmounting_disks/local_syslog_stop b/plugins/dynamix/event/unmounting_disks/local_syslog_stop index 0e81d882a..a42c16ac1 100755 --- a/plugins/dynamix/event/unmounting_disks/local_syslog_stop +++ b/plugins/dynamix/event/unmounting_disks/local_syslog_stop @@ -1,6 +1,6 @@ #!/bin/bash ETC=/etc/rsyslog.conf -if grep '/^\*\.\* \?remote$' $ETC; then +if grep -q '/^\*\.\* \?remote$' $ETC; then sed -ri 's/^(\*\.\* \?remote)$/#\1/' $ETC /etc/rc.d/rc.rsyslogd restart &> /dev/null fi From a9ef5afd0031ece1f76a7258bc6a759e3257aa09 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 7 Feb 2019 07:54:28 +0100 Subject: [PATCH 15/19] syslog: correction in event scripts --- plugins/dynamix/event/disks_mounted/local_syslog_start | 2 +- plugins/dynamix/event/unmounting_disks/local_syslog_stop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dynamix/event/disks_mounted/local_syslog_start b/plugins/dynamix/event/disks_mounted/local_syslog_start index 778833c4c..53cc13951 100755 --- a/plugins/dynamix/event/disks_mounted/local_syslog_start +++ b/plugins/dynamix/event/disks_mounted/local_syslog_start @@ -1,6 +1,6 @@ #!/bin/bash ETC=/etc/rsyslog.conf -if grep -q '/^#\*\.\* \?remote$' $ETC; then +if grep -qP '^#\*\.\* \?remote$' $ETC; then sed -ri 's/^#(\*\.\* \?remote)$/\1/' $ETC /etc/rc.d/rc.rsyslogd restart &> /dev/null fi diff --git a/plugins/dynamix/event/unmounting_disks/local_syslog_stop b/plugins/dynamix/event/unmounting_disks/local_syslog_stop index a42c16ac1..3f2559242 100755 --- a/plugins/dynamix/event/unmounting_disks/local_syslog_stop +++ b/plugins/dynamix/event/unmounting_disks/local_syslog_stop @@ -1,6 +1,6 @@ #!/bin/bash ETC=/etc/rsyslog.conf -if grep -q '/^\*\.\* \?remote$' $ETC; then +if grep -qP '^\*\.\* \?remote$' $ETC; then sed -ri 's/^(\*\.\* \?remote)$/#\1/' $ETC /etc/rc.d/rc.rsyslogd restart &> /dev/null fi From a52de746ebb60ecbdf0d5c4f9365e4dd9c769155 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 7 Feb 2019 08:48:09 +0100 Subject: [PATCH 16/19] Main: make disk identification mono-spaced font --- plugins/dynamix/include/DeviceList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/include/DeviceList.php b/plugins/dynamix/include/DeviceList.php index fd25d3694..4b67f8ac5 100644 --- a/plugins/dynamix/include/DeviceList.php +++ b/plugins/dynamix/include/DeviceList.php @@ -108,7 +108,7 @@ function device_desc(&$disk) { case 'Cache' : $type = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme'; break; } $log = $var['fsState']=='Started' ? "" : ""; - return $log.my_id($disk['id'])." - $size $unit ({$disk['device']})"; + return $log."".my_id($disk['id'])." - $size $unit ({$disk['device']})"; } function assignment(&$disk) { global $var, $devs; From 36e9740856cb7b24edd172b0e040b89d047a7812 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 7 Feb 2019 15:31:52 +0100 Subject: [PATCH 17/19] Added parity pause/resume button --- plugins/dynamix/ArrayOperation.page | 34 ++++++++++++++++++++------ plugins/dynamix/include/DeviceList.php | 12 ++++----- plugins/dynamix/scripts/monitor | 2 +- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/plugins/dynamix/ArrayOperation.page b/plugins/dynamix/ArrayOperation.page index f94154a4f..804da297b 100644 --- a/plugins/dynamix/ArrayOperation.page +++ b/plugins/dynamix/ArrayOperation.page @@ -159,7 +159,7 @@ function parityStatus() { if (data) {$.each(data.split(';'),function(k,v) {if ($('#line'+k).length>0) $('#line'+k).html(v);});} timers.parityStatus = setTimeout(parityStatus,3000); if (!data && $('#cancelButton').length>0 && $('#cancelButton').val()=='Cancel') { - $('#cancelButton').val('Done').unbind().bind({click:function(){refresh();}}); + $('#cancelButton').val('Done').prop('onclick',null).off('click').click(function(){refresh();}); $('#cancelText').html(''); $('#line4').html('completed'); } @@ -181,6 +181,16 @@ function stopParity(form,text) { form.submit(); } +function pauseParity(form) { + $(form).append(''); + $('#pauseButton').val('Resume').prop('onclick',null).off('click').click(function(){resumeParity(form);}); + form.submit(); +} +function resumeParity(form) { + $(form).append(''); + $('#pauseButton').val('Pause').prop('onclick',null).off('click').click(function(){pauseParity(form);}); + form.submit(); +} function shutdown_now(form,cmd) { $(form).append(''); @@ -196,7 +206,7 @@ parityStatus(); $('.tabs').append(ctrl); if ($.cookie('tab')=='tab0') $('i.toggle').hide(); -$('#tab'+$('input[name$="tabs"]').length).bind({click:function() {tab0(); $('i.toggle').hide('slow');}}); +$('#tab'+$('input[name$="tabs"]').length).click(function(){tab0(); $('i.toggle').hide('slow');}); $('div[id=title]:not(":last, .disable_diskio")').each(function(){$(this).append(ctrl);}); @@ -230,7 +240,7 @@ $(function(){ -0 ? '
Disabled -- Parity operation is running' : ''; +Disabled -- Parity operation is running' : ''; $mover = file_exists('/var/run/mover.pid') ? '
Disabled -- Mover is running' : ''; $btrfs = exec('pgrep -cf /sbin/btrfs') ? '
Disabled -- BTRFS operation is running' : ''; switch ($var['fsState']): @@ -248,7 +258,7 @@ $(function(){ Yes I want to do this All data is permanently lost !!!
This is not used to recover data

Format is never part of a rebuild
@@ -291,17 +301,25 @@ $(function(){ endif; else: if ($var['mdResyncAction']=="check"):?> - + - + - + - + diff --git a/plugins/dynamix/include/DeviceList.php b/plugins/dynamix/include/DeviceList.php index 4b67f8ac5..575af05b2 100644 --- a/plugins/dynamix/include/DeviceList.php +++ b/plugins/dynamix/include/DeviceList.php @@ -425,12 +425,12 @@ case 'open': break; case 'parity': $data = []; - if ($var['mdResync']>0) { - $data[] = my_scale($var['mdResync']*1024,$unit,-1)." $unit"; - $data[] = my_clock(floor((time()-$var['sbUpdated'])/60)); - $data[] = my_scale($var['mdResyncPos']*1024,$unit)." $unit (".number_format(($var['mdResyncPos']/($var['mdResync']/100+1)),1,$display['number'][0],'')." %)"; - $data[] = my_scale($var['mdResyncDb']*1024/$var['mdResyncDt'],$unit, 1)." $unit/sec"; - $data[] = my_clock(round(((($var['mdResyncDt']*(($var['mdResync']-$var['mdResyncPos'])/($var['mdResyncDb']/100+1)))/100)/60),0)); + if ($var['mdResyncPos']) { + $data[] = my_scale($var['mdResyncSize']*1024,$unit,-1)." $unit"; + $data[] = my_clock(floor((time()-$var['sbUpdated'])/60)).($var['mdResyncDt'] ? '' : ' (paused)'); + $data[] = my_scale($var['mdResyncPos']*1024,$unit)." $unit (".number_format(($var['mdResyncPos']/($var['mdResyncSize']/100+1)),1,$display['number'][0],'')." %)"; + $data[] = $var['mdResyncDt'] ? my_scale($var['mdResyncDb']*1024/$var['mdResyncDt'],$unit, 1)." $unit/sec" : '---'; + $data[] = $var['mdResyncDb'] ? my_clock(round(((($var['mdResyncDt']*(($var['mdResyncSize']-$var['mdResyncPos'])/($var['mdResyncDb']/100+1)))/100)/60),0)) : 'Unknown'; $data[] = $var['sbSyncErrs']; echo implode(';',$data); } else { diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index 30ddefce8..2411b7f98 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -287,7 +287,7 @@ if ($warn>0) { // process parity check, parity sync and data-rebuild notifications $name = 'parity'; $last = $saved[$item][$name] ?? ''; -if ($var['mdResync']>0) { +if ($var['mdResyncPos']) { if (!$last) { if (strstr($var['mdResyncAction'],"recon")) { $last = 'Parity sync / Data rebuild'; From 48e2ae14f7db5f8b89f20bb2e6fc48b04928bf7b Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 7 Feb 2019 15:49:24 +0100 Subject: [PATCH 18/19] Added parity pause/resume button --- plugins/dynamix/ArrayOperation.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/ArrayOperation.page b/plugins/dynamix/ArrayOperation.page index 804da297b..dbe7e5069 100644 --- a/plugins/dynamix/ArrayOperation.page +++ b/plugins/dynamix/ArrayOperation.page @@ -258,7 +258,7 @@ $(function(){ Yes I want to do this All data is permanently lost !!!
This is not used to recover data

Format is never part of a rebuild
From 6ec79c641cc109201703e3616c72e1dbad7adc97 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 7 Feb 2019 15:53:56 +0100 Subject: [PATCH 19/19] Added parity pause/resume button --- plugins/dynamix/ArrayOperation.page | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/dynamix/ArrayOperation.page b/plugins/dynamix/ArrayOperation.page index dbe7e5069..496a9ebd5 100644 --- a/plugins/dynamix/ArrayOperation.page +++ b/plugins/dynamix/ArrayOperation.page @@ -302,23 +302,23 @@ $(function(){ else: if ($var['mdResyncAction']=="check"):?>
Sync will start Parity-Sync and/or Data-Rebuild.
Read-Check in progress.
Read-Check in progress. + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + Cancel will stop the Read-Check.
Parity-Check in progress.
Parity-Check in progress. + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + Cancel will stop the Parity-Check.
Parity-Sync/Data-Rebuild in progress.
Parity-Sync/Data-Rebuild in progress. + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + Cancel will stop Parity-Sync/Data-Rebuild.
WARNING: canceling may leave the array unprotected!
Clearing in progress.
Clearing in progress. + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + Cancel will stop Clearing.
Current operation started on
Sync will start Parity-Sync and/or Data-Rebuild.
Read-Check in progress. - value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> Cancel will stop the Read-Check.
Parity-Check in progress. - value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> Cancel will stop the Parity-Check.
Parity-Sync/Data-Rebuild in progress. - value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> Cancel will stop Parity-Sync/Data-Rebuild.
WARNING: canceling may leave the array unprotected!
Clearing in progress. - value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> + value="Pause" onclick="pauseParity(this.form)" value="Resume" onclick="resumeParity(this.form)"> Cancel will stop Clearing.