feat: push-based monitoring with remote agent
- Add database migration 006 for agent_key, agent_installed, agent_install_path, agent_last_seen_at columns - Add Server model methods: findByAgentKey, generateAgentKey, regenerateAgentKey, updateAgentLastSeen, setAgentInstalled - Auto-generate agent_key on server creation - Create AgentService for SSH-based install/uninstall of remote agent - Create bin/agent.sh - bash agent script for remote servers - Create install/agent-install.sh and install/agent-uninstall.sh - Create install/servermanager-agent.service systemd unit - Add POST /api/metrics/push endpoint (auth via agent_key) - Add web routes for agent install/uninstall/regenerate-key - Add agent status section to server detail view with install/uninstall modals - Make MonitoringService::saveMetrics() public for reuse
This commit is contained in:
@@ -255,6 +255,40 @@ class ServerController
|
||||
]);
|
||||
}
|
||||
|
||||
public function agentInstall(int $id): void
|
||||
{
|
||||
$server = $this->requireServerAccess($id, 'manager');
|
||||
|
||||
$agentService = new \ServerManager\Services\AgentService();
|
||||
$result = $agentService->install($id);
|
||||
|
||||
$this->view->json($result);
|
||||
}
|
||||
|
||||
public function agentUninstall(int $id): void
|
||||
{
|
||||
$server = $this->requireServerAccess($id, 'manager');
|
||||
|
||||
$agentService = new \ServerManager\Services\AgentService();
|
||||
$result = $agentService->uninstall($id);
|
||||
|
||||
$this->view->json($result);
|
||||
}
|
||||
|
||||
public function agentRegenerateKey(int $id): void
|
||||
{
|
||||
$this->requireServerAccess($id, 'manager');
|
||||
|
||||
$newKey = $this->serverModel->regenerateAgentKey($id);
|
||||
|
||||
$this->auditService->log('agent_key_regenerated', 'server', $id);
|
||||
|
||||
$this->view->json([
|
||||
'success' => true,
|
||||
'agent_key' => $newKey,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testConnection(int $id): void
|
||||
{
|
||||
$server = $this->requireServerAccess($id, 'viewer');
|
||||
|
||||
Reference in New Issue
Block a user