5 Commits
Author SHA1 Message Date
Lizandro GuarnizoandClaude Sonnet 4.6 66088ce691 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>
2026-06-25 11:17:07 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 ae74d0ef90 feat(agent): persist 7-day metrics history per server heartbeat
- New table servidor_metricas_history (cpu%, ram%, swap%, disco%, tcp, load1)
- Each heartbeat inserts a compact row (~60 bytes)
- GET /app/servidor/:id/metricas-history?horas=24 returns the data
- Daily cron at 3AM purges rows older than 7 days
- ~1.2 MB per server per 7 days at 30s interval

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 11:03:16 -05:00
Lizandro Guarnizo f087fd46f1 up 2026-06-03 20:10:22 -05:00
Lizandro Guarnizo 0cf7c6d279 up 2026-05-21 22:37:31 -05:00
Lizandro GuarnizoandCopilot d9d3f8a5eb feat: sistema de agente ligero para monitoreo de servidores
Backend:
- Servidor model: AgentToken, AgentLastSeen, MetricasJson nuevos campos
- AgentHeartbeat: endpoint público POST /agent/heartbeat (auth por token)
- GenerateAgentToken: endpoint protegido POST /app/servidor/:id/agent-token
- Ruta pública /agent/install.sh sirve el script de instalación

Agente Go (agent/):
- agent/main.go: binario independiente con gopsutil
  - Recolecta RAM, CPU, Disco, Uptime, OS, Load average
  - Lee agent.yml o flags --api-url / --token
  - Envía POST a /agent/heartbeat cada N segundos
  - Instala como servicio systemd via install.sh
- agent/go.mod: módulo independiente (usite-agent)
- agent/agent.yml.sample: configuración de ejemplo
- agent/install.sh: instalador en 1 curl para Linux (systemd)

Frontend servidor_dashboard.html:
- Cards: badge ● En línea / ● Fuera / ○ Sin agente
- Barras de progreso live: RAM%, CPU%, Disco%
- Valores: GB usado/total, núcleos, uptime, OS real
- Tiempo desde último reporte
- Botón 'Agente' en cada card → modal de configuración
- Modal agente: estado, token con copy, comando curl 1 línea,
  instalación manual/avanzada con collapse, métricas actuales

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-21 11:29:24 -05:00