Say what Varaverk itself is using on the System card
The card described the machine and said nothing about the thing whose dashboard it is. Cache size matters most: VV_CACHE_ROOT is under /tmp, which on Unraid is RAM, so it is shown against the rootfs percentage it counts against. Jobs are locks with a live process — four lock files were sitting there and one job was actually running.
This commit is contained in:
@@ -329,6 +329,76 @@ function vv_watchdog_summary(): array {
|
||||
];
|
||||
}
|
||||
|
||||
// What Varaverk itself is occupying and doing, as opposed to what the machine is.
|
||||
//
|
||||
// The System card described the host — model, uptime, load — and said nothing about the thing
|
||||
// whose dashboard it is. These are the figures that are Varaverk's own and that nothing else on
|
||||
// the page reports.
|
||||
//
|
||||
// The cache size is the one worth watching. VV_CACHE_ROOT is /tmp/varaverk, and on Unraid /tmp is
|
||||
// on rootfs, which is RAM — so this directory is memory, not disk, and the arr payload cache is
|
||||
// most of it. master.conf says never to move these onto flash, which makes the size the thing to
|
||||
// keep an eye on instead. Reported next to the rootfs percentage it consumes, because 187 MB
|
||||
// means nothing without the ceiling it counts against.
|
||||
//
|
||||
// du rather than a recursive PHP walk: both roots are small and page-cached, measured at 3ms
|
||||
// each, and this is assembled once a minute by the cache writer rather than per page load.
|
||||
function vv_varaverk_state(): array {
|
||||
$du = function (string $path): ?int {
|
||||
if (!is_dir($path)) return null;
|
||||
$out = shell_exec('du -sb ' . escapeshellarg($path) . ' 2>/dev/null');
|
||||
return preg_match('/^(\d+)/', (string)$out, $m) ? (int)$m[1] : null;
|
||||
};
|
||||
|
||||
// Locks whose process is still alive. A lock file alone does not mean a job is running —
|
||||
// acquire_lock() clears one whose pid is gone, and three were sitting in LOCK_DIR from jobs
|
||||
// that finished days ago. Counting files would have reported four jobs running and one
|
||||
// actually was.
|
||||
$running = [];
|
||||
$stale = 0;
|
||||
foreach ((array)@glob('/tmp/unraid_locks/*.lock') as $lock) {
|
||||
$content = trim((string)@file_get_contents($lock));
|
||||
if ($content === '') { $stale++; continue; }
|
||||
[$pid, $name] = array_pad(explode(':', $content, 2), 2, '');
|
||||
$pid = (int)$pid;
|
||||
if ($pid > 1 && @posix_kill($pid, 0)) {
|
||||
$running[] = $name !== '' ? $name : basename($lock, '.lock');
|
||||
} else {
|
||||
$stale++;
|
||||
}
|
||||
}
|
||||
sort($running);
|
||||
|
||||
// Newest partner conf in the RAM cache. conf_sync fills it; an age climbing past its schedule
|
||||
// means the mesh has stopped talking, which nothing else on this page would show.
|
||||
$confAge = null;
|
||||
foreach ((array)@glob(VV_CONF_RAM_CACHE_DIR . '/host*.conf') as $c) {
|
||||
$m = @filemtime($c);
|
||||
if ($m && ($confAge === null || (time() - $m) < $confAge)) $confAge = time() - $m;
|
||||
}
|
||||
|
||||
// Storage mode as a fact about where this install actually is, not as the conf toggle's word
|
||||
// for it — the toggle is what someone intended and the path is what happened.
|
||||
//
|
||||
// "internal", not "flash". /boot is the internal mode in Varaverk's own vocabulary and on this
|
||||
// hardware it is a mirrored NVMe pool, not a USB stick; calling it flash on the dashboard
|
||||
// would invite a write-wear worry that does not apply here.
|
||||
$internal = str_starts_with(SCRIPTS_DIR, '/boot');
|
||||
|
||||
return [
|
||||
'cache_root' => VV_CACHE_ROOT,
|
||||
'cache_bytes' => $du(VV_CACHE_ROOT),
|
||||
'data_bytes' => $du(DATA_DIR),
|
||||
'scripts_dir' => SCRIPTS_DIR,
|
||||
'storage' => $internal ? 'internal' : 'appdata',
|
||||
'commit' => trim((string)shell_exec(
|
||||
'git -C ' . escapeshellarg(SCRIPTS_DIR) . ' rev-parse --short HEAD 2>/dev/null')),
|
||||
'jobs_running' => $running,
|
||||
'locks_stale' => $stale,
|
||||
'conf_age_sec' => $confAge,
|
||||
];
|
||||
}
|
||||
|
||||
function vv_scripts_status(): array {
|
||||
$logDir = LOG_DIR;
|
||||
$statFiles = array_merge(
|
||||
|
||||
Reference in New Issue
Block a user