Files
wevads-platform/api/health.php
2026-02-26 04:53:11 +01:00

33 lines
1.0 KiB
PHP

<?php
header('Content-Type: application/json');
$results = [];
try {
// Test DB
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
$results['database'] = ['status' => 'connected', 'tables' => []];
// Vérifier les tables critiques
$critical_tables = ['o365_accounts', 'smtp_servers', 'pmta_servers', 'domains'];
foreach ($critical_tables as $table) {
try {
$stmt = $pdo->query("SELECT COUNT(*) FROM $table");
$count = $stmt->fetchColumn();
$results['database']['tables'][$table] = ['exists' => true, 'rows' => $count];
} catch (Exception $e) {
$results['database']['tables'][$table] = ['exists' => false, 'error' => $e->getMessage()];
}
}
$results['status'] = 'healthy';
$results['timestamp'] = date('Y-m-d H:i:s');
} catch (Exception $e) {
$results['status'] = 'unhealthy';
$results['error'] = $e->getMessage();
}
echo json_encode($results, JSON_PRETTY_PRINT);
?>