Fix dead/incorrect vars in Plugin/ found during full codebase audit
- WEBGUI_PHP_WAIT was referenced by webgui_watchdog.sh but never defined
in master.conf, always silently falling back to a hardcoded default
- arrs.php/confform.php still pointed at Media/ for arr cleanup/discovery
scripts moved to Arrs_Stack/ in b4bc926 — broke the Arrs page's stats
and the per-script settings editor for those scripts
- docker_folders.php read directly from the optional folder.view3 plugin's
file instead of Varaverk's own docker_folders.json (the primary store
since the Docker tab got its own config) — left the Monitor page's
Docker Folders widget empty on any host without folder.view3 installed
- vv_wd_remote_data() read remote watchdog state files from hardcoded
/tmp or /boot/config paths instead of the remote's actual STATE_DIR
(which resolves dynamically and can differ under flash mode) — remote
node's Watchdog panel was always empty; same wrong path also used for
two local reads (system_watchdog_oom.db, watchdog_appdata_growth.db)
- rsync.php referenced a {HOST}_MONTHLY_SYNC_SHARES conf var that never
existed (monthly_maintenance.sh has no rsync section) — nulled out to
match the existing pattern used for the fallback window
- vv_arr_node_names() did a pointless identity array_map
- vv_dk_webui() had its own duplicate local-IP resolution instead of
using vv_local_ip(), despite config.php's comment claiming that exact
duplication was already consolidated
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -97,12 +97,7 @@ function vv_dk_webui(string $name, array $portMap): string {
|
||||
if (!preg_match('/<WebUI>(.*?)<\/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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
require_once __DIR__ . '/docker.php';
|
||||
|
||||
function vv_container_webui(string $name, array $portMap): string {
|
||||
$template = '/boot/config/plugins/dockerMan/templates-user/my-' . $name . '.xml';
|
||||
@@ -22,10 +23,10 @@ function vv_container_webui(string $name, array $portMap): string {
|
||||
}
|
||||
|
||||
function vv_get_docker_folders(): array {
|
||||
$folderFile = '/boot/config/plugins/folder.view3/docker.json';
|
||||
$folderData = file_exists($folderFile)
|
||||
? (json_decode(@file_get_contents($folderFile), true) ?: [])
|
||||
: [];
|
||||
// Varaverk's own docker_folders.json is the primary store (see include/docker.php) —
|
||||
// reading folder.view3's mirror directly here left this widget empty on any host
|
||||
// without that optional third-party plugin installed.
|
||||
$folderData = vv_dk_read_json();
|
||||
|
||||
// One docker ps call: names, status, port mappings
|
||||
$raw = shell_exec("docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Ports}}' 2>/dev/null") ?? '';
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user