feat(agent): auto-renice top CPU process after 2 consecutive high-CPU reports

- Agent tracks consecutive reports above cpu_threshold (default 90%)
- After renice_consecutive reports (default 2 = 60s sustained), runs
  renice -n 19 on the top CPU process
- Reports the action back in the heartbeat payload
- Backend sends Telegram alert when renice is applied
- All params configurable in agent.yml and install.sh flags

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-25 11:17:07 -05:00
co-authored by Claude Sonnet 4.6
parent fd72eec281
commit 66088ce691
4 changed files with 83 additions and 17 deletions
+8
View File
@@ -246,6 +246,14 @@ func sendTelegramPortalUser(chatID string, mensaje string) error {
return fmt.Errorf("no hay bots de Telegram activos para enviar")
}
// NotificarReniceAction envía Telegram cuando el agente aplica un renice automático.
func NotificarReniceAction(servidorNombre, accion string) {
msg := fmt.Sprintf("🔧 <b>Renice automático aplicado</b>\nServidor: <b>%s</b>\n%s\n\n<i>CPU sostenida por encima del umbral.</i>",
escapeTelegramHTML(servidorNombre),
escapeTelegramHTML(accion))
sendTelegramAdmin(msg)
}
func sendTelegramAdmin(mensaje string) {
configs, err := models.GetAllTelegramConfigs()
if err != nil {