<?php
header('Content-Type: application/json');
header('Cache-Control: no-cache, no-store');
require_once dirname(__DIR__) . '/include/monitor.php';

if (!isset($_GET['live'])) {
    $cached = vv_cache_read('monitor_remote', 3600);
    if ($cached) { echo json_encode($cached); exit; }
}

$data = ['remote_hosts' => vv_remote_hosts_stats(), 'ts' => time()];
vv_cache_write('monitor_remote', $data);
echo json_encode($data);
