Add Rsync page, upgrade monitor rsync card, partnership overhaul, API key periodic check, docker watchdog manual-stop detection
This commit is contained in:
@@ -367,10 +367,30 @@ function vv_rsync_status(): array {
|
||||
];
|
||||
}
|
||||
|
||||
// Profile activity — last 7 days, aggregated per profile
|
||||
$bwLog = DATA_DIR . '/bandwidth_history.db';
|
||||
$cutoff7 = date('Y-m-d', strtotime('-7 days'));
|
||||
$profiles = [];
|
||||
if (file_exists($bwLog)) {
|
||||
foreach (file($bwLog, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [] as $line) {
|
||||
$p = explode('|', $line);
|
||||
if (count($p) < 4 || ($p[0] ?? '') < $cutoff7) continue;
|
||||
$name = $p[2] ?? '';
|
||||
if (!$name) continue;
|
||||
if (!isset($profiles[$name])) $profiles[$name] = ['runs' => 0, 'dur' => 0, 'bytes' => 0];
|
||||
$profiles[$name]['runs']++;
|
||||
$profiles[$name]['dur'] += (int)($p[3] ?? 0);
|
||||
$profiles[$name]['bytes'] += (int)($p[5] ?? 0);
|
||||
}
|
||||
}
|
||||
arsort($profiles); // sort by run count descending
|
||||
$bwSummary = array_slice($profiles, 0, 6, true);
|
||||
|
||||
return [
|
||||
'enabled' => $enabled,
|
||||
'windows' => $windows,
|
||||
'active' => $active,
|
||||
'last_sync' => $lastSync,
|
||||
'enabled' => $enabled,
|
||||
'windows' => $windows,
|
||||
'active' => $active,
|
||||
'last_sync' => $lastSync,
|
||||
'bw_summary' => $bwSummary,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user