remove monitor.php — SSH pull monitoring replaced by push-based agent

This commit is contained in:
2026-06-13 15:49:35 -04:00
parent a9f21810b1
commit 6c6ad957bc
4 changed files with 3 additions and 68 deletions

View File

@@ -241,11 +241,8 @@ configure_cron() {
log_step "Configuring Cron Jobs"
cat > /etc/cron.d/servermanager << CRONEOF
# ServerManager Monitoring Cron
# Collect metrics every minute
* * * * * www-data /usr/bin/php ${APP_DIR}/bin/monitor.php >> ${APP_DIR}/logs/cron.log 2>&1
# Cleanup old logs weekly
# ServerManager Cron Jobs
# Logs cleanup — weekly
0 3 * * 0 www-data find ${APP_DIR}/logs/ -name "*.log" -mtime +30 -delete
CRONEOF
@@ -259,32 +256,6 @@ create_binaries() {
mkdir -p "${APP_DIR}/bin"
cat > "${APP_DIR}/bin/monitor.php" << 'PHPEOF'
<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
use ServerManager\Core\App;
use ServerManager\Services\MonitoringService;
try {
$app = App::getInstance();
$app->boot(dirname(__DIR__));
$monitoring = new MonitoringService();
$results = $monitoring->collectAllMetrics();
$online = count(array_filter($results, fn($r) => $r && ($r['status'] ?? '') === 'online'));
$offline = count($results) - $online;
echo sprintf("[%s] Metrics collected: %d servers (%d online, %d offline)\n",
date('Y-m-d H:i:s'), count($results), $online, $offline);
} catch (\Throwable $e) {
echo sprintf("[%s] ERROR: %s\n", date('Y-m-d H:i:s'), $e->getMessage());
exit(1);
}
PHPEOF
cat > "${APP_DIR}/bin/generate-key.php" << 'PHPEOF'
<?php
declare(strict_types=1);
@@ -307,7 +278,6 @@ echo "Master key generated: {$keyFile}\n";
echo "IMPORTANT: Store this key securely!\n";
PHPEOF
chmod +x "${APP_DIR}/bin/monitor.php"
chmod +x "${APP_DIR}/bin/generate-key.php"
chown -R rafael:rafael "${APP_DIR}/bin"