Files
anjuma-dashboard/api/pve_status.php
T
2026-07-22 01:12:45 +02:00

19 lines
533 B
PHP

<?php
require_once __DIR__ . '/../lib/PveApi.php';
$cfg = require __DIR__ . '/../config/pve.php';
$pve = new PveApi($cfg);
header('Content-Type: application/json; charset=utf-8');
try {
$vmid = (int)($_GET['vmid'] ?? 0);
if ($vmid <= 0) throw new InvalidArgumentException("vmid fehlt/ungültig");
$data = $pve->statusCurrent($vmid);
echo json_encode(['ok' => true, 'vmid' => $vmid, 'data' => $data]);
} catch (Throwable $e) {
http_response_code(400);
echo json_encode(['ok' => false, 'error' => $e->getMessage()]);
}