From fa3532e46f2e858e7396a03b2fc12a7ff67e9637 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 17:23:14 +0200 Subject: [PATCH 1/6] Revised service reload functionality --- emhttp/plugins/dynamix/scripts/reload_services | 3 +-- sbin/create_network_ini | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 2d91748b4..41ebc59bb 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -2,11 +2,10 @@ SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" job=/tmp/atjob.tmp -[[ -n $1 && -e $job ]] && exit 0 -touch $job for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done +rm -f $job exit 0 diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 8072f0ac2..f90d84bf3 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -222,8 +222,10 @@ done /usr/bin/mv $ini ${ini%.*} # delayed execution -rm -f $job -echo "sleep 35;$reload job"|at -M now 2>/dev/null +if [[ ! -f $job ]]; then + echo "sleep 35;$reload"|at -M now 2>/dev/null + touch $job +fi # send update information if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then From 64c5690b068c9c3561a9d8c8ea56e6063db2a9d7 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 06:45:49 +0200 Subject: [PATCH 2/6] Revert "Revised service reload functionality" This reverts commit fa3532e46f2e858e7396a03b2fc12a7ff67e9637. --- emhttp/plugins/dynamix/scripts/reload_services | 3 ++- sbin/create_network_ini | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 41ebc59bb..2d91748b4 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -2,10 +2,11 @@ SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" job=/tmp/atjob.tmp +[[ -n $1 && -e $job ]] && exit 0 +touch $job for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done -rm -f $job exit 0 diff --git a/sbin/create_network_ini b/sbin/create_network_ini index f90d84bf3..8072f0ac2 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -222,10 +222,8 @@ done /usr/bin/mv $ini ${ini%.*} # delayed execution -if [[ ! -f $job ]]; then - echo "sleep 35;$reload"|at -M now 2>/dev/null - touch $job -fi +rm -f $job +echo "sleep 35;$reload job"|at -M now 2>/dev/null # send update information if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then From bb3c0c0b9a299adb8fe2c1d0a8293f5fa51ac781 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 08:48:08 +0200 Subject: [PATCH 3/6] NTP: fix listening interfaces --- etc/rc.d/rc.library.source | 2 +- etc/rc.d/rc.ntpd | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index f2e5eed8e..6bbb5dc8a 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -157,7 +157,7 @@ check() { fi done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^fe80" {print $1,$3}') # add loopback interface - if [[ "smb nfs ntp" =~ $CALLER ]]; then + if [[ "smb nfs" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index 02c91cede..f9319ae41 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -21,12 +21,10 @@ build_ntp() { # ignore unused protocol [[ $ipv4 == no ]] && echo "interface ignore ipv4" >>$CONF [[ $ipv6 == no ]] && echo "interface ignore ipv6" >>$CONF - # for now do not bind interfaces - # it is not clear why NTP is started several times and fails to bind on occasion # add listen interfaces - #for net in $bind; do - # echo "interface listen $net" >>$CONF - #done + for net in $bind; do + echo "interface listen $net" >>$CONF + done fi # add configured NTP servers [[ -n $NTP_SERVER1 ]] && echo "server $NTP_SERVER1 iburst" >>$CONF From 1070b46d3e8689c403dd4d51b551ca4edacf92e0 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 09:32:34 +0200 Subject: [PATCH 4/6] NTP: fix listening interfaces --- etc/rc.d/rc.ntpd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index f9319ae41..71c6d38c8 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -92,7 +92,7 @@ ntpd_reload() { ntpd_update() { [[ $(pgrep -cf $NTPD) -eq 0 ]] && exit 1 # not running - if check && [[ -z "$(this 'interface listen')" || "$(this 'interface listen')" == "$bind" ]]; then + if check && [[ "$(this 'interface listen')" == "$bind" ]]; then # no action required exit 1 else From cbbdc001e268429167bb5ae464dfa08bb7065511 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 09:35:45 +0200 Subject: [PATCH 5/6] Dashboard: show ZFS percentage based on c_max value --- emhttp/plugins/dynamix/nchan/update_1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/nchan/update_1 b/emhttp/plugins/dynamix/nchan/update_1 index 429a33e96..dc1a416bb 100755 --- a/emhttp/plugins/dynamix/nchan/update_1 +++ b/emhttp/plugins/dynamix/nchan/update_1 @@ -17,16 +17,15 @@ $varroot = '/var/local/emhttp'; require_once "$docroot/webGui/include/publish.php"; while (true) { - unset($memory,$sys,$rpms,$lsof); + unset($memory,$sys,$zfs,$rpms,$lsof); exec("grep -Po '^Mem(Total|Available):\s+\K\d+' /proc/meminfo",$memory); exec("df /boot /var/log /var/lib/docker|grep -Po '\d+%'",$sys); exec("sensors -uA 2>/dev/null|grep -Po 'fan\d_input: \K\d+'",$rpms); + exec("awk '/^c_max|^size/{print \$3}' /proc/spl/kstat/zfs/arcstats 2>/dev/null",$zfs); [$total,$free] = $memory; $used = $total-$free; - $zfs = (exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0)/1024; - $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*$zfs/$used)."%\0".implode("\0",$sys); + $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*($zfs[1]?:0)/($zfs[0]?:1))."%\0".implode("\0",$sys); $rpms = count($rpms) ? implode(" RPM\0",$rpms).' RPM' : ''; - $names = array_keys((array)parse_ini_file("$varroot/shares.ini")); exec("LANG='en_US.UTF8' lsof -Owl /mnt/disk[0-9]* 2>/dev/null|awk '/^shfs/ && \$0!~/\.AppleD(B|ouble)/ && \$5==\"REG\"'|awk -F/ '{print \$4}'",$lsof); $counts = array_count_values($lsof); $count = []; From 002327476bcba7c2a57608edf15b028a1b6fe55a Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 09:41:33 +0200 Subject: [PATCH 6/6] Dashboard: show ZFS percentage based on c_max value --- emhttp/plugins/dynamix/nchan/update_1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/nchan/update_1 b/emhttp/plugins/dynamix/nchan/update_1 index dc1a416bb..3937a3830 100755 --- a/emhttp/plugins/dynamix/nchan/update_1 +++ b/emhttp/plugins/dynamix/nchan/update_1 @@ -24,7 +24,7 @@ while (true) { exec("awk '/^c_max|^size/{print \$3}' /proc/spl/kstat/zfs/arcstats 2>/dev/null",$zfs); [$total,$free] = $memory; $used = $total-$free; - $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*($zfs[1]?:0)/($zfs[0]?:1))."%\0".implode("\0",$sys); + $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*($zfs[1]??0)/($zfs[0]??1))."%\0".implode("\0",$sys); $rpms = count($rpms) ? implode(" RPM\0",$rpms).' RPM' : ''; $names = array_keys((array)parse_ini_file("$varroot/shares.ini")); exec("LANG='en_US.UTF8' lsof -Owl /mnt/disk[0-9]* 2>/dev/null|awk '/^shfs/ && \$0!~/\.AppleD(B|ouble)/ && \$5==\"REG\"'|awk -F/ '{print \$4}'",$lsof);