66 lines
2.8 KiB
PHP
66 lines
2.8 KiB
PHP
<?php
|
|
// V9.47 Andon Drilldown API · doctrine #13 root cause visibility
|
|
header("Content-Type: application/json");
|
|
header("Access-Control-Allow-Origin: *");
|
|
|
|
$host = "127.0.0.1";
|
|
$port = "5432";
|
|
$db = "adx_system";
|
|
$user = "admin";
|
|
$pass = "admin123";
|
|
|
|
putenv("PGPASSWORD=$pass");
|
|
|
|
$sql = "SELECT id, station, severity, message, status, created_at::text, resolved_at::text, triggered_by, resolved_by, owner, resolution_path FROM weval.andon_alerts ORDER BY status='open' DESC, severity, created_at DESC LIMIT 50";
|
|
$cmd = "psql -h $host -p $port -U $user -d $db -At -F'|' -c " . escapeshellarg($sql) . " 2>&1";
|
|
$out = shell_exec($cmd);
|
|
|
|
$rows = [];
|
|
foreach (explode("\n", trim($out)) as $line) {
|
|
if (empty($line)) continue;
|
|
$f = explode("|", $line);
|
|
if (count($f) < 11) continue;
|
|
$rows[] = [
|
|
"id" => $f[0],
|
|
"station" => $f[1],
|
|
"severity" => $f[2],
|
|
"message" => $f[3],
|
|
"status" => $f[4],
|
|
"created_at" => $f[5],
|
|
"resolved_at" => $f[6],
|
|
"triggered_by" => $f[7],
|
|
"resolved_by" => $f[8],
|
|
"owner" => $f[9],
|
|
"resolution_path" => $f[10],
|
|
"drilldown_info" => drilldown_info($f[1])
|
|
];
|
|
}
|
|
|
|
function drilldown_info($station) {
|
|
$map = [
|
|
"cash-OKP4" => ["type"=>"commercial", "action"=>"Relance facture Yacine", "contact"=>"Kaouther/OKP4", "url"=>"/wevia-life-app/crm"],
|
|
"sales-vistex" => ["type"=>"commercial", "action"=>"Email Olga Vistex addendum", "contact"=>"Olga Vistex", "url"=>"/wevia-life-app/deals"],
|
|
"saas-churn" => ["type"=>"seed_data", "action"=>"Fake seed resolved doctrine 4", "contact"=>"N/A", "url"=>null, "note"=>"Not real business data"],
|
|
"blade-agent-exec" => ["type"=>"infra", "action"=>"Restart via intent blade_wake or wevia_blade_restart", "contact"=>"Yacineutt Windows", "url"=>"/api/blade-agent.php"],
|
|
"cybersec-nuclei" => ["type"=>"infra", "action"=>"V9.41 scan = 0 findings", "contact"=>"N/A", "url"=>"/api/nuclei-scanner.php"],
|
|
"Apps" => ["type"=>"infra", "action"=>"V9.43 symlinks fix", "contact"=>"N/A", "url"=>"/"],
|
|
"EM-Platform" => ["type"=>"infra", "action"=>"V9.46 investigating", "contact"=>"N/A", "url"=>null],
|
|
"dispensation-station-3" => ["type"=>"ethica", "action"=>"Scanner fallback manuel", "contact"=>"N/A", "url"=>"/ethica-hub.html"]
|
|
];
|
|
return $map[$station] ?? ["type"=>"unknown", "action"=>"Investigate", "contact"=>"TBD", "url"=>null];
|
|
}
|
|
|
|
$open = array_filter($rows, fn($r) => $r["status"] === "open");
|
|
$summary = [
|
|
"ok" => true,
|
|
"ts" => date("c"),
|
|
"source" => "adx_system.weval.andon_alerts",
|
|
"total" => count($rows),
|
|
"open" => count($open),
|
|
"resolved" => count($rows) - count($open),
|
|
"drilldown_map_version" => "v9.47",
|
|
"alerts" => $rows
|
|
];
|
|
|
|
echo json_encode($summary, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|