true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query(['username' => PMX_USER, 'password' => PMX_PASS]), CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_TIMEOUT => 6, ]); $r = json_decode(curl_exec($ch), true); curl_close($ch); return $r['data'] ?? null; } function pmx_get(string $path, array $auth): ?array { $ch = curl_init(PMX_HOST.'/api2/json'.$path); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_TIMEOUT => 6, CURLOPT_HTTPHEADER => ['Cookie: PVEAuthCookie='.$auth['ticket']], ]); $r = json_decode(curl_exec($ch), true); curl_close($ch); return $r['data'] ?? null; } function fmt_bytes(int $b): string { if ($b >= 1073741824) return round($b/1073741824, 1).' GB'; if ($b >= 1048576) return round($b/1048576, 1).' MB'; return round($b/1024, 1).' KB'; } function fmt_uptime(int $s): string { $d = intdiv($s, 86400); $h = intdiv($s % 86400, 3600); $m = intdiv($s % 3600, 60); return $d ? "{$d}d {$h}h" : ($h ? "{$h}h {$m}m" : "{$m}m"); } function pct_color(float $p): string { if ($p >= 85) return '#f85149'; if ($p >= 60) return '#d29922'; return '#3fb950'; } $auth = pmx_auth(); $error = null; $node = $containers = $vms = null; if (!$auth) { $error = 'Não foi possível autenticar na API do Proxmox.'; } else { $node = pmx_get('/nodes/'.PMX_NODE.'/status', $auth); $storage = pmx_get('/nodes/'.PMX_NODE.'/storage', $auth) ?? []; $containers = pmx_get('/nodes/'.PMX_NODE.'/lxc', $auth) ?? []; $vms = pmx_get('/nodes/'.PMX_NODE.'/qemu', $auth) ?? []; usort($containers, fn($a,$b) => $a['vmid'] <=> $b['vmid']); usort($vms, fn($a,$b) => $a['vmid'] <=> $b['vmid']); $storage = array_filter($storage, fn($s) => ($s['active'] ?? 0) && ($s['total'] ?? 0) > 0); usort($storage, fn($a,$b) => strcmp($a['storage'], $b['storage'])); } $title = 'Proxmox'; ob_start(); ?>
= 0): ?>
de

Containers LXC ()

IDNomeEstadoCPURAMUptime
running % /

VMs ()

IDNomeEstadoCPURAMUptime
running % /