diff --git a/Configurations/master.conf b/Configurations/master.conf index a5e7db7..4776292 100644 --- a/Configurations/master.conf +++ b/Configurations/master.conf @@ -948,6 +948,7 @@ WEBGUI_URL="http://localhost" WEBGUI_TIMEOUT=5 # seconds before curl gives up on WebGUI check WEBGUI_NGINX_WAIT=15 # seconds after nginx restart before rechecking + WEBGUI_PHP_WAIT=10 # seconds after php-fpm restart before rechecking WEBGUI_EMHTTP_WAIT=30 # seconds after emhttp restart before rechecking # ============================================================================================== diff --git a/Deployment/master.conf.template b/Deployment/master.conf.template index f46c34b..e5e4886 100644 --- a/Deployment/master.conf.template +++ b/Deployment/master.conf.template @@ -943,6 +943,7 @@ WEBGUI_URL="http://localhost" WEBGUI_TIMEOUT=5 # seconds before curl gives up on WebGUI check WEBGUI_NGINX_WAIT=15 # seconds after nginx restart before rechecking + WEBGUI_PHP_WAIT=10 # seconds after php-fpm restart before rechecking WEBGUI_EMHTTP_WAIT=30 # seconds after emhttp restart before rechecking # ============================================================================================== diff --git a/Plugin/unraid/Watchdogs/System/webgui_watchdog.sh b/Plugin/unraid/Watchdogs/System/webgui_watchdog.sh index 649a011..bcba840 100755 --- a/Plugin/unraid/Watchdogs/System/webgui_watchdog.sh +++ b/Plugin/unraid/Watchdogs/System/webgui_watchdog.sh @@ -123,7 +123,7 @@ if [[ "$SHOW_STATUS" == true ]]; then echo "━━━━━ $ICON_SUMMARY WEBGUI WATCHDOG STATUS ━━━━━" echo "$ICON_HOST Identity: $MY_ID ($LOCAL_SERVER_NAME)" echo "$ICON_WEBGUI URL: $WEBGUI_URL" - echo "$ICON_WEBGUI Timeouts: curl=${WEBGUI_TIMEOUT}s nginx=${WEBGUI_NGINX_WAIT}s php=${WEBGUI_PHP_WAIT:-10}s emhttp=${WEBGUI_EMHTTP_WAIT}s" + echo "$ICON_WEBGUI Timeouts: curl=${WEBGUI_TIMEOUT}s nginx=${WEBGUI_NGINX_WAIT}s php=${WEBGUI_PHP_WAIT}s emhttp=${WEBGUI_EMHTTP_WAIT}s" echo "" if curl -sf --max-time "$WEBGUI_TIMEOUT" "$WEBGUI_URL" >/dev/null 2>&1; then @@ -227,8 +227,8 @@ if [[ "$RECOVERY_OK" == false ]]; then error "php-fpm restart command failed" fi - log "Waiting ${WEBGUI_PHP_WAIT:-10}s for php-fpm to recover..." - sleep "${WEBGUI_PHP_WAIT:-10}" + log "Waiting ${WEBGUI_PHP_WAIT}s for php-fpm to recover..." + sleep "$WEBGUI_PHP_WAIT" if check_webgui; then RECOVERY_ACTION="php-fpm restart" diff --git a/Plugin/unraid/api/rsync.php b/Plugin/unraid/api/rsync.php index 190c1e4..206a5e7 100644 --- a/Plugin/unraid/api/rsync.php +++ b/Plugin/unraid/api/rsync.php @@ -83,7 +83,8 @@ $winArrayDefs = [ 'intermediate' => ['INTERMEDIATE_MAINTENANCE_SCRIPTS', "{$myId}_INTERMEDIATE_SYNC_SHARES"], 'daily' => ['DAILY_MAINTENANCE_SCRIPTS', "{$myId}_DAILY_SYNC_SHARES"], 'weekly' => ['WEEKLY_MAINTENANCE_SCRIPTS', "{$myId}_WEEKLY_SYNC_SHARES"], - 'monthly' => ['MONTHLY_MAINTENANCE_SCRIPTS', "{$myId}_MONTHLY_SYNC_SHARES"], + // monthly_maintenance.sh has no rsync section (ZFS scrub/SMART tests only) — no shares var exists. + 'monthly' => ['MONTHLY_MAINTENANCE_SCRIPTS', null], 'fallback' => [null, null], ]; $winArrays = []; diff --git a/Plugin/unraid/include/arrs.php b/Plugin/unraid/include/arrs.php index 9a8b7db..52653d1 100644 --- a/Plugin/unraid/include/arrs.php +++ b/Plugin/unraid/include/arrs.php @@ -14,7 +14,7 @@ function vv_arr_known_hosts(): array { } function vv_arr_node_names(): array { - return array_map(fn($name) => $name, vv_arr_known_hosts()); + return vv_arr_known_hosts(); } // ── Discovery ───────────────────────────────────────────────────────────────── @@ -123,9 +123,9 @@ function vv_fetch_arr_live(array $arr): array { // ── Log stats ───────────────────────────────────────────────────────────────── function vv_arr_cleanup_stats(string $type): array { - $slugs = ['sonarr' => 'Media/sonarr_cleanup', - 'radarr' => 'Media/radarr_cleanup', - 'lidarr' => 'Media/lidarr_cleanup']; + $slugs = ['sonarr' => 'Arrs_Stack/sonarr_cleanup', + 'radarr' => 'Arrs_Stack/radarr_cleanup', + 'lidarr' => 'Arrs_Stack/lidarr_cleanup']; $base = LOG_DIR . '/' . ($slugs[$type] ?? ''); $out = ['last_run' => null, 'end' => null, 'status' => null, 'tracked' => null, 'total' => null, @@ -181,9 +181,9 @@ function vv_arr_cleanup_stats(string $type): array { } function vv_arr_discovery_stats(string $type): array { - $slugs = ['sonarr' => 'Media/playback_aware_sonarr_discovery', - 'radarr' => 'Media/playback_aware_radarr_discovery', - 'lidarr' => 'Media/playback_aware_lidarr_discovery']; + $slugs = ['sonarr' => 'Arrs_Stack/playback_aware_sonarr_discovery', + 'radarr' => 'Arrs_Stack/playback_aware_radarr_discovery', + 'lidarr' => 'Arrs_Stack/playback_aware_lidarr_discovery']; $base = LOG_DIR . '/' . ($slugs[$type] ?? ''); $out = ['last_run' => null, 'status' => null, 'added' => null]; @@ -225,7 +225,7 @@ function vv_arr_discovery_stats(string $type): array { } function vv_arr_sync_stats(): array { - $base = LOG_DIR . '/Media/arr_sync'; + $base = LOG_DIR . '/Arrs_Stack/arr_sync'; $out = ['last_run' => null, 'status' => null, 'added' => null, 'nodes' => null, 'blocklist_count' => null]; @@ -255,7 +255,7 @@ function vv_arr_sync_stats(): array { } function vv_arr_recovery_stats(): array { - $base = LOG_DIR . '/Media/arrs_failed_stalled_recovery'; + $base = LOG_DIR . '/Arrs_Stack/arrs_failed_stalled_recovery'; $out = ['last_run' => null, 'status' => null, 'fixed' => 0, 'searched' => 0]; $jf = $base . '.json'; diff --git a/Plugin/unraid/include/confform.php b/Plugin/unraid/include/confform.php index 1970d1a..a5b9590 100644 --- a/Plugin/unraid/include/confform.php +++ b/Plugin/unraid/include/confform.php @@ -28,10 +28,11 @@ const VV_SCRIPT_CONF_SECTIONS = [ // Media 'Media/media_cleaner.sh' => ['Media Cleaner'], 'Media/media_shares_permissions.sh' => ['Media Permissions'], - 'Media/arrs_failed_stalled_recovery.sh' => ['Arr Failed/Stalled Recovery'], - 'Media/radarr_cleanup.sh' => ['Arr Cleanup'], - 'Media/lidarr_cleanup.sh' => ['Arr Cleanup'], - 'Media/sonarr_cleanup.sh' => ['Arr Cleanup'], + // Arrs Stack + 'Arrs_Stack/arrs_failed_stalled_recovery.sh' => ['Arr Failed/Stalled Recovery'], + 'Arrs_Stack/radarr_cleanup.sh' => ['Arr Cleanup'], + 'Arrs_Stack/lidarr_cleanup.sh' => ['Arr Cleanup'], + 'Arrs_Stack/sonarr_cleanup.sh' => ['Arr Cleanup'], // Monitors 'Monitors/cert_monitor.sh' => ['Certificate Monitor'], 'Monitors/backup_verify.sh' => ['Backup Verify'], diff --git a/Plugin/unraid/include/docker.php b/Plugin/unraid/include/docker.php index e5c1388..dd41f1f 100644 --- a/Plugin/unraid/include/docker.php +++ b/Plugin/unraid/include/docker.php @@ -97,12 +97,7 @@ function vv_dk_webui(string $name, array $portMap): string { if (!preg_match('/(.*?)<\/WebUI>/s', $xml, $m)) return ''; $url = trim($m[1]); if (!$url) return ''; - static $localIp = null; - if ($localIp === null) { - $localIp = trim(shell_exec("ip route get 8.8.8.8 2>/dev/null | awk '/src/{for(i=1;i<=NF;i++)if(\$i==\"src\")print \$(i+1)}'") ?: ''); - if (!$localIp) $localIp = gethostbyname(gethostname()); - } - $url = str_replace('[IP]', $localIp, $url); + $url = str_replace('[IP]', vv_local_ip(), $url); $url = preg_replace_callback('/\[PORT:(\d+)\]/', fn($pm) => $portMap[$pm[1]] ?? $pm[1], $url); return $url; } diff --git a/Plugin/unraid/include/docker_folders.php b/Plugin/unraid/include/docker_folders.php index c86c788..871b663 100644 --- a/Plugin/unraid/include/docker_folders.php +++ b/Plugin/unraid/include/docker_folders.php @@ -1,5 +1,6 @@ /dev/null") ?? ''; diff --git a/Plugin/unraid/include/watchdog.php b/Plugin/unraid/include/watchdog.php index 0b43c9c..e358367 100644 --- a/Plugin/unraid/include/watchdog.php +++ b/Plugin/unraid/include/watchdog.php @@ -83,7 +83,7 @@ function vv_wd_local_system(): array { $mem = vv_memory_breakdown(); $loadRaw = @file_get_contents('/proc/loadavg') ?: '0'; $daemonOk = (trim(shell_exec('docker info >/dev/null 2>&1; echo $?') ?: '1') === '0'); - $oomCount = (int)trim(@file_get_contents('/tmp/system_watchdog_oom.db') ?: '0'); + $oomCount = (int)trim(@file_get_contents(STATE_DIR . '/system_watchdog_oom.db') ?: '0'); $cores = (int)($sys['cpu_cores'] ?: (int)(trim(shell_exec('nproc 2>/dev/null') ?: '1'))); return [ 'mem_total' => (int)($mem['total_kb'] * 1024), @@ -155,7 +155,7 @@ function vv_wd_local_states(string $restartLogPath): array { } // Growth baseline info (container count + age in seconds) - $growthFile = '/tmp/watchdog_appdata_growth.db'; + $growthFile = STATE_DIR . '/watchdog_appdata_growth.db'; $baselineCount = file_exists($growthFile) ? max(0, count(file($growthFile)) - 0) : 0; $baselineAgeSec = file_exists($growthFile) ? time() - (int)filemtime($growthFile) : null; @@ -187,23 +187,28 @@ function vv_wd_remote_data(string $ip, string $sshKey, string $restartLogPath): // /proc/meminfo is passed as a raw section (not awk-parsed) to avoid quoting // fragility — escapeshellarg() single-quotes the whole command so awk \$2 // inside double-quotes is unreliable across Unraid builds. - $cmd = "printf 'UPTIME:%s\nLOAD:%s\nCORES:%s\nDAEMON:%s\nOOM:%s\nBASELINECOUNT:%s\nBASELINEAGE:%s\n---MEMINFO---\n%s\n---RW---\n%s\n---DOCK---\n%s\n---SKIP---\n%s\n---SYS---\n%s\n---REBOOT---\n%s\n---RESTART---\n%s\n---STORAGE---\n%s\n---NETWORK---\n%s\n' " + // State files live under the REMOTE's own SCRIPTS_DIR/State_Files (may differ + // from ours in flash mode) — resolve it once, same idiom as vv_remote_state_cmd(). + $restartLogName = basename($restartLogPath); + $cmd = 'sd=$(grep -m1 SCRIPTS_DIR= /boot/config/plugins/varaverk/varaverk.cfg 2>/dev/null' + . ' | cut -d\'"\' -f2); sd="${sd:-/boot/config/plugins/varaverk}"; ' + . "printf 'UPTIME:%s\nLOAD:%s\nCORES:%s\nDAEMON:%s\nOOM:%s\nBASELINECOUNT:%s\nBASELINEAGE:%s\n---MEMINFO---\n%s\n---RW---\n%s\n---DOCK---\n%s\n---SKIP---\n%s\n---SYS---\n%s\n---REBOOT---\n%s\n---RESTART---\n%s\n---STORAGE---\n%s\n---NETWORK---\n%s\n' " . '"$(cat /proc/uptime|cut -d\" \" -f1)" ' . '"$(cat /proc/loadavg|cut -d\" \" -f1)" ' . '"$(nproc)" ' . '"$(docker info >/dev/null 2>&1 && echo ok || echo err)" ' - . '"$(cat /tmp/system_watchdog_oom.db 2>/dev/null||echo 0)" ' - . '"$(wc -l < /tmp/watchdog_appdata_growth.db 2>/dev/null||echo 0)" ' - . '"$(stat -c %Y /tmp/watchdog_appdata_growth.db 2>/dev/null||echo 0)" ' + . '"$(cat "$sd/State_Files/system_watchdog_oom.db" 2>/dev/null||echo 0)" ' + . '"$(wc -l < "$sd/State_Files/watchdog_appdata_growth.db" 2>/dev/null||echo 0)" ' + . '"$(stat -c %Y "$sd/State_Files/watchdog_appdata_growth.db" 2>/dev/null||echo 0)" ' . '"$(cat /proc/meminfo 2>/dev/null)" ' - . '"$(cat /tmp/resource_watchdog_state.db 2>/dev/null)" ' - . '"$(cat /tmp/container_watchdog_state.db 2>/dev/null)" ' - . '"$(cat /boot/config/system_watchdog_failed.db 2>/dev/null)" ' - . '"$(cat /tmp/system_watchdog_state.db 2>/dev/null)" ' - . '"$(cat /boot/config/system_watchdog_reboots.db 2>/dev/null)" ' - . '"$(cat ' . escapeshellarg($restartLogPath) . ' 2>/dev/null)" ' - . '"$(cat /tmp/storage_watchdog_state.db 2>/dev/null)" ' - . '"$(cat /tmp/network_watchdog_state.db 2>/dev/null)"'; + . '"$(cat "$sd/State_Files/resource_watchdog_state.db" 2>/dev/null)" ' + . '"$(cat "$sd/State_Files/container_watchdog_state.db" 2>/dev/null)" ' + . '"$(cat "$sd/State_Files/docker_watchdog_failed.db" 2>/dev/null)" ' + . '"$(cat "$sd/State_Files/system_watchdog_state.db" 2>/dev/null)" ' + . '"$(cat "$sd/State_Files/system_watchdog_reboots.db" 2>/dev/null)" ' + . '"$(cat "$sd/data/' . $restartLogName . '" 2>/dev/null)" ' + . '"$(cat "$sd/State_Files/storage_watchdog_state.db" 2>/dev/null)" ' + . '"$(cat "$sd/State_Files/network_watchdog_state.db" 2>/dev/null)"'; $out = vv_pt_ssh($ip, $sshKey, $cmd, 8); if (!$out) return null;