Put everything Varaverk persists under one root, state included

This commit is contained in:
Gmer4Lfe
2026-08-08 23:26:46 -04:00
parent d5c36db531
commit f1603349cc
11 changed files with 420 additions and 77 deletions
+8 -4
View File
@@ -200,14 +200,18 @@ function vv_watchdog_summary(): array {
}
// Recent restarts (24 h)
$restartLog = DATA_DIR . '/container_restart_history.db';
$restartLog = DB_DIR . '/container_restart_history.db';
$restartRaw = @file_get_contents($restartLog) ?: '';
$cutoff = time() - 86400;
$restarts = [];
foreach (explode("\n", trim($restartRaw)) as $line) {
if (!$line || !str_contains($line, '|')) continue;
[$name, $ts] = explode('|', $line, 2);
if ((int)$ts >= $cutoff) $restarts[] = ['name' => trim($name), 'ts' => (int)$ts];
// The second field is a formatted local date, not an epoch — see
// vv_wd_restart_ts() in watchdog.php for why, and for what casting it with (int)
// silently did to this list for as long as it has existed.
[$name, $raw] = explode('|', $line, 2);
$ts = vv_wd_restart_ts(trim($raw));
if ($ts >= $cutoff) $restarts[] = ['name' => trim($name), 'ts' => $ts];
}
usort($restarts, fn($a, $b) => $b['ts'] - $a['ts']);
@@ -422,7 +426,7 @@ function vv_rsync_status(): array {
}
// Profile activity — last 7 days, aggregated per profile
$bwLog = DATA_DIR . '/bandwidth_history.db';
$bwLog = DB_DIR . '/bandwidth_history.db';
$cutoff7 = date('Y-m-d', strtotime('-7 days'));
$profiles = [];
if (file_exists($bwLog)) {