64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
require_once('/opt/wevads/config/credentials.php');
|
|
/**
|
|
* Brain Server Optimizer - Frontend Wrapper
|
|
* Backend: /opt/wevads/scripts/brain-server-optimizer.py
|
|
* Connected to: adx_system DB (admin schema)
|
|
*/
|
|
|
|
$page_title = "Brain Server Optimizer";
|
|
$page_icon = "fas fa-microchip";
|
|
|
|
$db = get_pg('adx_system');
|
|
if (!$db) die("DB connection failed");
|
|
pg_query($db, "SET search_path TO admin, public");
|
|
|
|
if (isset($_GET['action'])) {
|
|
header('Content-Type: application/json');
|
|
$action = $_GET['action'];
|
|
|
|
switch ($action) {
|
|
case 'status':
|
|
$result = pg_query($db, "SELECT count(*) as total FROM servers WHERE status = 'active'");
|
|
echo json_encode(pg_fetch_assoc($result));
|
|
break;
|
|
case 'run':
|
|
$output = shell_exec("python3 /opt/wevads/scripts/brain-server-optimizer.py 2>&1");
|
|
echo json_encode(['output' => $output]);
|
|
break;
|
|
}
|
|
exit;
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head><title><?= $page_title ?> - WEVADS</title>
|
|
<style>
|
|
body { background: #0f172a; color: #e2e8f0; font-family: system-ui; margin: 0; padding: 20px; }
|
|
.card { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 20px; margin-bottom: 16px; }
|
|
h1 { color: #22d3ee; }
|
|
.btn { background: #0891b2; color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; }
|
|
.btn:hover { background: #0e7490; }
|
|
pre { background: #0f172a; padding: 12px; border-radius: 8px; overflow-x: auto; }
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
<h1><i class="<?= $page_icon ?>"></i> <?= $page_title ?></h1>
|
|
<div class="card">
|
|
<p>Optimisation automatique des serveurs</p>
|
|
<button class="btn" onclick="runScript()">▶ Optimiser serveurs</button>
|
|
<pre id="output">En attente...</pre>
|
|
</div>
|
|
<script>
|
|
async function runScript() {
|
|
document.getElementById('output').textContent = 'Optimisation en cours...';
|
|
const r = await fetch('?action=run');
|
|
const d = await r.json();
|
|
document.getElementById('output').textContent = d.output || 'Terminé';
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|