varaverk: System card (identity/time/uptime/buttons); merge Fallback+Partner into one card

This commit is contained in:
Gmer4Lfe
2026-05-24 12:00:09 -04:00
parent 725c371f21
commit 359b051e64
5 changed files with 147 additions and 49 deletions
@@ -3,6 +3,47 @@ require_once __DIR__ . '/config.php';
// Monitor helpers — docker, GPU, resources, transcode sessions, fallback state.
function vv_system_info(): array {
// Identity from ident.cfg
$ident = @parse_ini_file('/boot/config/ident.cfg') ?: [];
// Registration from var.ini
$var = [];
foreach (@file('/var/local/emhttp/var.ini') ?: [] as $line) {
if (preg_match('/^(\w+)="([^"]*)"/', $line, $m)) $var[$m[1]] = $m[2];
}
// CPU model
$cpu = '';
foreach (@file('/proc/cpuinfo') ?: [] as $line) {
if (preg_match('/^model name\s*:\s*(.+)/', $line, $m)) { $cpu = trim($m[1]); break; }
}
// Uptime
$uptimeSec = (int)explode(' ', @file_get_contents('/proc/uptime') ?: '0')[0];
$days = intdiv($uptimeSec, 86400);
$hours = intdiv($uptimeSec % 86400, 3600);
$mins = intdiv($uptimeSec % 3600, 60);
$uptime = ($days > 0 ? "{$days}d " : '')
. ($hours > 0 ? "{$hours}h " : '')
. "{$mins}m";
// Array state
$arrayState = $var['mdState'] ?? 'UNKNOWN';
return [
'name' => $ident['NAME'] ?? gethostname(),
'comment' => $ident['COMMENT'] ?? '',
'timezone' => $ident['timeZone'] ?? 'UTC',
'cpu_model' => $ident['SYS_MODEL'] ?? $cpu,
'reg_type' => 'Unraid OS ' . ($var['regTy'] ?? ''),
'reg_to' => $var['regTo'] ?? '',
'uptime' => $uptime,
'array_state' => $arrayState,
'version' => trim(@file_get_contents('/etc/unraid-version') ?: ''),
];
}
function vv_docker_containers(): array {
$out = shell_exec('docker ps --format \'{"name":"{{.Names}}","status":"{{.Status}}","image":"{{.Image}}"}\' 2>/dev/null');
$containers = [];