Files
jarvis/api/endpoints/proxmox.php
T
myron dc55e6c45b Initial commit: JARVIS AI dashboard v2.3
- 4-tier chat: HA control → Ollama → Groq → Claude
- Push-based agent system with heartbeat/metrics
- Network monitoring, alerts, Proxmox, Home Assistant
- Windows + Linux agent installers
- Stats cache cron, facts collector, KB engine
2026-05-25 13:22:57 +00:00

42 lines
1.3 KiB
PHP

<?php
// Proxmox API endpoint — serves from api_cache, refreshed every 5 min by cron
$isConfigured = !(PROXMOX_HOST === '10.48.200.X' || PROXMOX_TOKEN_VAL === 'YOUR_TOKEN_VALUE_HERE');
if (!$isConfigured) {
echo json_encode([
'configured' => false,
'message' => 'Proxmox API token not yet configured.',
'vms' => [], 'nodes' => [],
]);
exit;
}
// Serve from cache (refreshed by stats_cache.php cron every 5 min)
$cached = JarvisDB::query(
'SELECT data, UNIX_TIMESTAMP(updated_at) as updated_ts FROM api_cache WHERE cache_key=? LIMIT 1',
['proxmox']
);
if ($cached && !empty($cached[0]['data'])) {
$row = $cached[0];
$data = json_decode($row['data'], true);
// Add cache age to response
$data['cache_age_s'] = (int)(time() - (int)$row['updated_ts']);
echo json_encode($data);
} else {
// Cache empty — return placeholder so UI shows something useful
echo json_encode([
'configured' => true,
'node' => PROXMOX_NODE,
'node_status' => null,
'vms' => [],
'containers' => [],
'vm_count' => 0,
'ct_count' => 0,
'cached_at' => null,
'cache_age_s' => -1,
'message' => 'Cache warming up — first update in under 5 minutes.',
]);
}