lecturehalls-dashboard/public/get.php
2024-09-09 11:41:02 +02:00

26 lines
833 B
PHP

<?php
header('content-type: application/json');
$conf = parse_ini_file('../config.ini', true);
$dbconf = $conf['database'];
$db = new mysqli($dbconf['host'],
$dbconf['user'],
$dbconf['pass'],
$dbconf['database'],
$dbconf['port']);
$result = $db->query('select o.* from results as o
inner join (select host, max(timestamp) as latest
from results group by host)
as i on o.host= i.host
where o.timestamp = i.latest');
$out = [];
foreach($result as $row) {
$out[$row['host']] = ['time' => $row['timestamp'],
'status' => $row['returncode'],
'detail' => $row['detail']];
}
print(json_encode($out));
?>