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:
@@ -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