mirror of
https://github.com/myronblair/novacpx
synced 2026-06-30 17:50:41 -05:00
feat: server monitoring charts, package limits, WHMCS bridge, server options (#19-22)
#19 Server monitoring charts: - server_stats table (migration 007) + collect-stats.php cron script - serverStatus() page rebuilt with Chart.js line charts (CPU/RAM/disk) - Chart.js lazy-loaded from CDN; history shown for last 24h #20 Cron job manager: already complete in prior session #21 Package limits enforcement: - email.php: checks max_email before creating email account - databases.php: checks max_databases before creating database - ftp.php: checks max_ftp before creating FTP account - stats.php: fixed column names (max_email/max_ftp/max_databases vs old aliases) #22b WHMCS billing bridge: - whmcs.php endpoint: create/suspend/unsuspend/terminate/changepackage/info - Auth via X-WHMCS-Key header; enabled/key stored in settings table #22a/c/d/e Server options admin page: - Web/mail/FTP/DNS server selection with settings persistence - Server switch triggers /opt/novacpx/bin/switch-*.sh scripts (if present) - NS health checker: live dig lookup of all zones vs configured NS1/NS2 - system.php: server-options + save-option actions - dns.php: ns-health action Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -97,5 +97,29 @@ match ($action) {
|
||||
Response::success(['domain' => $domain, 'results' => $results]);
|
||||
})(),
|
||||
|
||||
// ── NS Health Checker (#22e) ─────────────────────────────────────────────
|
||||
'ns-health' => (function() use ($db) {
|
||||
Auth::getInstance()->require('admin');
|
||||
$ns1 = $db->fetchOne("SELECT value FROM settings WHERE `key`='ns1_hostname'")['value'] ?? '';
|
||||
$ns2 = $db->fetchOne("SELECT value FROM settings WHERE `key`='ns2_hostname'")['value'] ?? '';
|
||||
$zones = $db->fetchAll("SELECT domain FROM dns_zones ORDER BY domain LIMIT 200");
|
||||
$results = [];
|
||||
foreach ($zones as $z) {
|
||||
$domain = $z['domain'];
|
||||
$raw = shell_exec("dig +short NS " . escapeshellarg($domain) . " 2>/dev/null") ?? '';
|
||||
$nsRecords = array_filter(array_map('trim', explode("\n", $raw)));
|
||||
$foundNs1 = $ns1 ? in_array(rtrim($ns1,'.').'.', array_map(fn($n)=>rtrim($n,'.').'.', $nsRecords)) : null;
|
||||
$foundNs2 = $ns2 ? in_array(rtrim($ns2,'.').'.', array_map(fn($n)=>rtrim($n,'.').'.', $nsRecords)) : null;
|
||||
$results[] = [
|
||||
'domain' => $domain,
|
||||
'ns1' => $nsRecords[0] ?? null,
|
||||
'ns2' => $nsRecords[1] ?? null,
|
||||
'ok' => ($ns1 ? $foundNs1 : true) && ($ns2 ? $foundNs2 : true),
|
||||
'ns_raw' => $nsRecords,
|
||||
];
|
||||
}
|
||||
Response::success(['results' => $results, 'expected_ns1' => $ns1, 'expected_ns2' => $ns2]);
|
||||
})(),
|
||||
|
||||
default => Response::error("Unknown dns action: $action", 404),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user