<?php
require __DIR__ . "/../api/monitoring/koneksi.php";

$total = $conn->query("SELECT COUNT(*) c FROM pc_clients")->fetch_assoc()['c'];

$online = $conn->query("
    SELECT COUNT(*) c FROM pc_clients
    WHERE last_seen >= NOW() - INTERVAL 2 MINUTE
")->fetch_assoc()['c'];

echo json_encode([
    "total" => (int)$total,
    "online" => (int)$online,
    "offline" => (int)$total - (int)$online
]);
