Add Rsync card to monitor page Row 3 (before GPU)
New span-1 card shows global RSYNC_ENABLED gate, per-window badges (C/D/I/W), active profile names + elapsed time from lock files, and last-sync timestamp per orchestrator window from script log files. GPU shrunk from span 2 to span 1 to make room. Row 3 is now: Rsync(1) | GPU(1) | Transcode(2) | Streams(4)
This commit is contained in:
@@ -319,3 +319,58 @@ function vv_scripts_status(): array {
|
||||
'error_count' => count(array_filter($scripts, fn($s) => $s['status'] === 'error')),
|
||||
];
|
||||
}
|
||||
|
||||
function vv_rsync_status(): array {
|
||||
$vars = vv_conf_vars();
|
||||
|
||||
$enabled = ($vars['RSYNC_ENABLED'] ?? 'true') !== 'false';
|
||||
|
||||
$windows = [
|
||||
'critical' => ($vars['CRITICAL_RSYNC_ENABLED'] ?? 'false') !== 'false',
|
||||
'daily' => ($vars['DAILY_RSYNC_ENABLED'] ?? 'false') !== 'false',
|
||||
'intermediate' => ($vars['INTERMEDIATE_RSYNC_ENABLED'] ?? 'true') !== 'false',
|
||||
'weekly' => ($vars['WEEKLY_RSYNC_ENABLED'] ?? 'false') !== 'false',
|
||||
];
|
||||
|
||||
// Active rsync profiles — from lock files
|
||||
$lockDir = '/tmp/unraid_locks';
|
||||
$active = [];
|
||||
foreach (glob("$lockDir/rsync_*.lock") ?: [] as $lf) {
|
||||
$content = trim(@file_get_contents($lf) ?: '');
|
||||
[$pid, $locked_name] = array_pad(explode(':', $content, 2), 2, '');
|
||||
if (!$pid || !file_exists("/proc/$pid")) continue;
|
||||
$profile = preg_replace('/^rsync_/', '', $locked_name ?: basename($lf, '.lock'));
|
||||
$active[] = [
|
||||
'profile' => $profile,
|
||||
'pid' => (int)$pid,
|
||||
'elapsed' => time() - (int)filemtime($lf),
|
||||
];
|
||||
}
|
||||
|
||||
// Last completed run per window (orchestrator log files)
|
||||
$scriptMap = [
|
||||
'critical' => 'critical_sync_maintenance',
|
||||
'daily' => 'daily_sync_maintenance',
|
||||
'intermediate' => 'intermediate_sync_maintenance',
|
||||
'weekly' => 'weekly_sync_maintenance',
|
||||
];
|
||||
$lastSync = [];
|
||||
foreach ($scriptMap as $key => $scriptName) {
|
||||
$logFile = LOG_DIR . "/$scriptName.json";
|
||||
if (!file_exists($logFile)) continue;
|
||||
$stat = json_decode(@file_get_contents($logFile) ?: '{}', true) ?: [];
|
||||
$lastSync[$key] = [
|
||||
'ts' => (int)($stat['end'] ?? $stat['start'] ?? 0),
|
||||
'status' => $stat['status'] ?? 'unknown',
|
||||
'duration' => isset($stat['start'], $stat['end'])
|
||||
? (int)$stat['end'] - (int)$stat['start'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'enabled' => $enabled,
|
||||
'windows' => $windows,
|
||||
'active' => $active,
|
||||
'last_sync' => $lastSync,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user