From a7387c27fb7b8cb03fd15de5e33ea3d9463ab752 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Fri, 14 Aug 2026 16:06:02 -0400 Subject: [PATCH] Mark watchdog list entries that name a container which no longer exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Half the hard-pressure stop list is containers that are not installed, so at level 3 it sheds half the memory the card implies. Badged on the lists where a dead entry costs something and deliberately not on Scan ignore, where ignoring something already gone is the point — a card of dashed pills by design would teach the eye to skip the badge where it has to be believed. --- Plugin/unraid/include/watchdog.php | 16 ++++++ Plugin/unraid/pages/watchdog.php | 82 ++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 10 deletions(-) diff --git a/Plugin/unraid/include/watchdog.php b/Plugin/unraid/include/watchdog.php index 2c36f99..ff43af1 100644 --- a/Plugin/unraid/include/watchdog.php +++ b/Plugin/unraid/include/watchdog.php @@ -68,6 +68,22 @@ require_once __DIR__ . '/partnership.php'; // until it doesn't and fails silently in the direction of hiding a real strike. const VV_WD_SYS_BOOKKEEPING = ['watchdog_cycle']; +// Every container that exists on this host, running or not, for deciding whether a name in a +// watchdog list still refers to anything. +// +// `docker ps -a` rather than vv_docker_containers() + vv_docker_stopped(): those two are filtered +// by status and between them still miss states like restarting, and a container this page called +// "not installed" because it happened to be mid-restart would be worse than not checking at all. +// The whole point of the badge is that it is only ever shown when it is certainly true. +// +// Returns an empty array when docker cannot be reached, and callers must treat that as "unknown" +// rather than "nothing is installed" — otherwise a docker outage marks every entry dead. +function vv_wd_installed_containers(): array { + @exec("docker ps -a --format '{{.Names}}' 2>/dev/null", $out, $rc); + if ($rc !== 0) return []; + return array_values(array_filter(array_map('trim', $out), fn($n) => $n !== '')); +} + // ── Conf array parser (bash arrays) ────────────────────────────────────────── function vv_wd_bash_array(string $raw, string $varname): array { diff --git a/Plugin/unraid/pages/watchdog.php b/Plugin/unraid/pages/watchdog.php index 036246d..bcded00 100644 --- a/Plugin/unraid/pages/watchdog.php +++ b/Plugin/unraid/pages/watchdog.php @@ -45,6 +45,9 @@ // include/ai_chat.php → the shared chat component require_once dirname(__DIR__) . '/include/confui.php'; require_once dirname(__DIR__) . '/include/ai_chat.php'; +// For vv_wd_installed_containers() only. The state on this page still arrives entirely through +// api/watchdog.php — this include buys one function, not a second collection path. +require_once dirname(__DIR__) . '/include/watchdog.php'; ?>