44 lines
1.4 KiB
PHP
Executable File
44 lines
1.4 KiB
PHP
Executable File
|
|
<?php
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
try {
|
|
$db = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
|
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
$action = $_GET['action'] ?? 'dashboard';
|
|
|
|
if ($action === 'dashboard') {
|
|
// Quotas
|
|
$quotas = $db->query("SELECT * FROM admin.cloud_quotas ORDER BY provider_name")->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// Alertes
|
|
$alerts = $db->query("SELECT * FROM admin.cloud_alerts WHERE status='active' ORDER BY created_at DESC LIMIT 10")->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// Stats
|
|
$stats = $db->query("
|
|
SELECT
|
|
COUNT(*) as total_providers,
|
|
SUM(CASE WHEN status='ok' THEN 1 ELSE 0 END) as healthy,
|
|
SUM(CASE WHEN status='warning' THEN 1 ELSE 0 END) as warning,
|
|
SUM(CASE WHEN status='critical' THEN 1 ELSE 0 END) as critical
|
|
FROM admin.cloud_quotas
|
|
")->fetch(PDO::FETCH_ASSOC);
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'quotas' => $quotas,
|
|
'alerts' => $alerts,
|
|
'stats' => $stats
|
|
], JSON_PRETTY_PRINT);
|
|
}
|
|
|
|
} catch(Exception $e) {
|
|
echo json_encode([
|
|
'success' => false,
|
|
'error' => $e->getMessage()
|
|
], JSON_PRETTY_PRINT);
|
|
}
|
|
|