diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/monitor.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/monitor.php index 8822aa9..bb895b0 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/api/monitor.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/monitor.php @@ -3,6 +3,7 @@ header('Content-Type: application/json'); require_once dirname(__DIR__) . '/include/monitor.php'; echo json_encode([ + 'system' => vv_system_info(), 'fallback' => vv_fallback_state(), 'fallback_active' => vv_fallback_active(), 'partner' => vv_partner_state(), diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/system.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/system.php new file mode 100644 index 0000000..9631f5c --- /dev/null +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/system.php @@ -0,0 +1,20 @@ + false, 'error' => 'invalid action']); + exit; +} + +$cmd = match($action) { + 'stop' => '/usr/local/sbin/mdcmd stop', + 'shutdown' => '/sbin/shutdown -h now', + 'restart' => '/sbin/shutdown -r now', +}; + +exec($cmd . ' > /dev/null 2>&1 &'); +echo json_encode(['ok' => true]); diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css b/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css index 030e006..11ed20d 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css +++ b/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css @@ -16,6 +16,14 @@ .vv-card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: #888; letter-spacing: 0.05em; } +/* System card — no h3, no top padding waste */ +#vv-system { padding-top: 14px; } + +/* System action buttons */ +.vv-sys-btn { background: #2a2a2a; border: 1px solid #444; color: #888; border-radius: 4px; + padding: 3px 7px; font-size: 13px; cursor: pointer; line-height: 1; } +.vv-sys-btn:hover { background: #3a3a3a; color: #ccc; border-color: #666; } + /* Fallback state badge */ .vv-state-badge { font-size: 20px; font-weight: bold; padding: 4px 0; margin-bottom: 2px; } .vv-state-normal { color: #4caf50; } diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php b/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php index a801a27..ea6d531 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php @@ -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 = []; diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php b/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php index 07c9021..0bf68e5 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php @@ -3,13 +3,12 @@