Commit Graph

126 Commits

Author SHA1 Message Date
ab9e5d9cf3 Merge pull request 'fix: force LC_ALL=C for metric commands to avoid comma decimal separator' (#51) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #51
2026-06-11 20:50:31 -04:00
552e30751d fix: force LC_ALL=C for metric commands to avoid comma decimal separator
Some locales use comma as decimal separator (e.g., es_DO.UTF-8).
This caused invalid JSON like "cpu": 2,4 instead of "cpu": 2.4.
Prefixed CPU and RAM commands with LC_ALL=C to force dot decimals.

Also removed debug logging from pushMetrics endpoint.
2026-06-11 20:49:14 -04:00
50f1574954 Merge pull request 'feat/push-monitoring-agent-v2' (#50) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #50
2026-06-11 20:43:53 -04:00
2340fce8f8 fix: use warning level for push metrics log 2026-06-11 20:39:28 -04:00
ef23dd0b08 fix: add logging to pushMetrics endpoint for debugging 401 2026-06-11 20:39:14 -04:00
b90c600573 Merge pull request 'fix: unquote PAYLOAD heredoc so runtime vars are expanded' (#49) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #49
2026-06-11 20:35:58 -04:00
ddf4d744c6 fix: unquote PAYLOAD heredoc so runtime vars are expanded
The inner PAYLOAD heredoc had a quoted delimiter ('PAYLOAD') which
prevented runtime variable expansion. Changed to unquoted (PAYLOAD)
so $AGENT_KEY, $CPU, etc. are correctly expanded at runtime.

The double-escaping works as:
  install time (outer EOF):  $AGENT_KEY  →   (in file)
  runtime (inner PAYLOAD):     →  abc123... (actual value)
2026-06-11 20:35:24 -04:00
1d99bff390 Merge pull request 'fix: escape runtime vars in unquoted heredoc, eliminate sed dependency' (#48) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #48
2026-06-11 20:34:06 -04:00
a1e3723a97 fix: escape runtime vars in unquoted heredoc, eliminate sed dependency
The unquoted EOF heredoc expands all $ at install time. Runtime
variables inside functions (CPU, RAM, AGENT_KEY, etc.) must be
escaped with $ to prevent premature expansion.

Also removed the fragile sed replace step entirely — values are now
embedded directly when the heredoc is expanded.
2026-06-11 20:33:11 -04:00
2373e2b227 Merge pull request 'fix: use correct server URL instead of localhost' (#47) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #47
2026-06-11 20:29:39 -04:00
26e35c6bc7 fix: use ['HTTP_HOST'] dynamically for agent URL 2026-06-11 20:28:35 -04:00
4d3a7e4d65 fix: use correct server URL instead of localhost
AgentService now replaces 'localhost' in the server URL with
sysadmin.lan before sending to the remote agent. Also added
URL/hostname debug output to the agent startup log.
2026-06-11 20:26:37 -04:00
db29f5b50b Merge pull request 'fix: remove set -e from agent, guard all commands with || true' (#46) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #46
2026-06-11 20:22:21 -04:00
cc0a0c0644 fix: remove set -e from agent, guard all commands with || true
- Removed 'set -e' so a failing metric collection command doesn't kill
  the agent process
- Added '|| true' to every command in collect_metrics() to prevent
  pipeline failures
- Fixed push_metrics() to capture curl exit code with 'local code; code=$(...) || code=0'
- The agent now keeps running even if individual metrics or push fail
2026-06-11 20:21:24 -04:00
b5ebeb7ba6 Merge pull request 'fix: embed config directly in agent script, remove external config file' (#45) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #45
2026-06-11 19:45:30 -04:00
b27e1392ca fix: embed config directly in agent script, remove external config file
The values SERVER_URL, AGENT_KEY, INTERVAL are now written directly
into the agent bash script using @placeholder@ substitution with sed.
No config file lookup needed — eliminates the 'not configured' error.

Config file directory (/etc/servermanager, ~/.config/servermanager)
is no longer created or referenced.
2026-06-11 19:44:30 -04:00
05cf026867 Merge pull request 'fix: agent config search order — 1st arg > /etc/ > ~/.config/' (#44) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #44
2026-06-11 19:39:13 -04:00
93d5f24d0f fix: agent config search order — 1st arg > /etc/ > ~/.config/
The systemd service runs as root so /root is /root, but config is
written to /etc/servermanager/agent.conf. The agent now tries:
1. Path from command-line argument
2. /etc/servermanager/agent.conf (system mode)
3. $HOME/.config/servermanager/agent.conf (user mode)

Service ExecStart and cron job both pass the config path explicitly.
2026-06-11 19:38:10 -04:00
589524b1d0 Merge pull request 'feat: push-based monitoring with remote agent (v2)' (#43) from feat/push-monitoring-agent-v2 into master
Reviewed-on: #43
Reviewed-by: rafaga21 <rafaelminaya20@hotmail.com>
2026-06-11 19:34:41 -04:00
4ae9443016 Revert "fix: agent now searches both /etc/servermanager and ~/.config for config"
This reverts commit fe997750ff.
2026-06-11 19:33:29 -04:00
3a263a692f Merge pull request 'fix: agent now searches both /etc/servermanager and ~/.config for config' (#42) from feat/push-monitoring-agent into master
Reviewed-on: #42
2026-06-11 19:27:27 -04:00
fe997750ff fix: agent now searches both /etc/servermanager and ~/.config for config
The embedded agent binary checks /etc/servermanager/agent.conf first
(system mode), then falls back to ~/.config/servermanager/agent.conf
(user mode).
2026-06-11 19:24:25 -04:00
20e3a6926f Merge pull request 'fix: dual-mode installer — works with or without sudo' (#41) from feat/push-monitoring-agent into master
Reviewed-on: #41
2026-06-11 19:14:59 -04:00
fd3cc6825c fix: dual-mode installer — works with or without sudo
Installer now detects at runtime if it can get root access:
- Root/NOPASSWD sudo: installs to system directories with systemd
- No root: installs to ~/.local/bin with @reboot cron job

Self-elevation uses 'script -qc sudo bash' for requiretty, or falls
back to user mode without hanging on password prompts.

Uninstaller checks both system and user paths.
2026-06-11 19:12:57 -04:00
76180271ce Merge pull request 'feat: push-based monitoring with remote agent (self-elevating installer)' (#40) from feat/push-monitoring-agent into master
Reviewed-on: #40
Reviewed-by: rafaga21 <rafaelminaya20@hotmail.com>
2026-06-11 19:09:09 -04:00
0edc882f2e fix: installer self-elevates with script PTY instead of external sudo chain
- agent-install.sh and agent-uninstall.sh now detect if running as root
  at startup and re-execute via 'script -qc sudo bash' if needed
- AgentService commands simplified: just write to /tmp and run bash,
  the scripts handle privilege escalation internally
- Fixes exit code propagation: the script's exit code now correctly
  flows back through exec -> script -> sudo -> bash -> SSH
2026-06-11 19:07:14 -04:00
08ee59663b Merge pull request 'fix: use script command for PTY instead of modifying SSHService' (#39) from feat/push-monitoring-agent into master
Reviewed-on: #39
2026-06-11 19:02:34 -04:00
0ce24c4b8f fix: use script command for PTY instead of modifying SSHService
- Revert SSHService exec() back to original (remove PTY parameter)
- AgentService now writes installer to /tmp/ first, then runs via
  script -q -c to create a PTY for sudo (handles requiretty)
- Falls back to direct sudo bash if script is unavailable
- Cleans up temp files after execution
- Added mkdir -p for /usr/local/bin in installer
- Added file verification and byte-count after writing agent binary
2026-06-11 19:01:27 -04:00
00062e4d4a Merge pull request 'fix: allocate PTY for agent install to work with sudo requiretty' (#38) from feat/push-monitoring-agent into master
Reviewed-on: #38
2026-06-11 18:53:19 -04:00
63bf125420 fix: allocate PTY for agent install to work with sudo requiretty
The remote server has 'Defaults requiretty' in sudoers, which prevents
sudo from running without a TTY. Modified SSHService::exec() to accept
an optional  parameter that allocates a pseudo-terminal, and
extracts the exit status from output when PTY is used (since phpseclib
doesn't return exit status in PTY mode).
2026-06-11 18:52:40 -04:00
5f6788970f Merge pull request 'feat: push-based monitoring with remote agent' (#37) from feat/push-monitoring-agent into master
Reviewed-on: #37
Reviewed-by: rafaga21 <rafaelminaya20@hotmail.com>
2026-06-11 18:50:21 -04:00
f4c534c020 fix: always use sudo for agent install (remove fallback check)
The sudo -n check was incorrectly detecting that sudo required a
password, causing fallback to plain bash without root permissions.
Now we always run the installer via sudo bash, consistent with how
all other SSH commands work (systemctl, reboot, etc.).
2026-06-11 18:48:23 -04:00
28d2dfecce Merge pull request 'fix: add sudo fallback to agent installer + improve error output' (#36) from feat/push-monitoring-agent into master
Reviewed-on: #36
2026-06-11 18:46:13 -04:00
85bb70fe0f fix: add sudo fallback to agent installer + improve error output
- AgentService: try sudo -n first, fall back to bash without sudo
- AgentService: add sudo to uninstall command
- AgentService: trim error output to last 20 lines for readability
- View: show SSH output inline in error toast
- Fix undefined $path variable in success path
2026-06-11 18:45:14 -04:00
16044445d4 Merge pull request 'feat: push-based monitoring with remote agent' (#35) from feat/push-monitoring-agent into master
Reviewed-on: #35
2026-06-11 18:31:47 -04:00
bfa102cf97 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
2026-06-11 18:28:22 -04:00
fcd8565890 Merge pull request 'fix: filtrar servidores por usuario/equipo segun rol' (#34) from fix/server-access-filtering into master
Reviewed-on: #34
Reviewed-by: rafaga21 <rafaelminaya20@hotmail.com>
2026-06-11 17:27:23 -04:00
6e4bf2ad1d build: compile APK v1.7.0 (versionCode 9) 2026-06-11 17:26:54 -04:00
1bc8236d4d fix: filtrar servidores por usuario/equipo según rol
- Server::getAccessibleServerIds(): super_admin ve todos los servidores;
  admin y operator solo ven propios, asignados directos o por equipo
- DashboardController: unifica lógica usando getAccessibleServerIds()
- ServerController::metrics(): agrega control de acceso requireServerAccess()
- ApiController::status(): filtra estadísticas por servidores accesibles
- Android: bump versionCode 9, versionName 1.7.0
2026-06-11 13:09:53 -04:00
830161ad87 Merge pull request 'docs: update AGENTS.md — verified against current codebase' (#33) from feat/android-v1.6.0 into master
Reviewed-on: #33
2026-06-09 19:49:58 -04:00
dec6aa3527 docs: update AGENTS.md — verified against current codebase 2026-06-09 19:49:15 -04:00
d52cb9ae8b Merge pull request 'fix: show stopped services in list + loading bar on action' (#32) from feat/android-v1.6.0 into master
Reviewed-on: #32
2026-06-09 19:32:00 -04:00
4d00f0d8b1 bump to 1.6.1 2026-06-09 19:31:42 -04:00
92bc12355c fix: show stopped services in list + loading bar on action
- API: --all flag in systemctl list-units to show inactive services
- API: removed head -50 limit
- Android: LinearProgressIndicator while service action is running
2026-06-09 19:29:36 -04:00
90b4d62486 Merge pull request 'fix: allow dots in service names for systemd (nginx.service, ssh.service)' (#31) from feat/android-v1.6.0 into master
Reviewed-on: #31
2026-06-09 19:25:57 -04:00
96a73384c4 fix: allow dots in service names for systemd (nginx.service, ssh.service) 2026-06-09 19:25:14 -04:00
9c63ed8e53 Merge pull request 'v1.6.0 — fix service 500, search bar, modal redesign' (#30) from feat/android-v1.6.0 into master
Reviewed-on: #30
Reviewed-by: rafaga21 <rafaelminaya20@hotmail.com>
2026-06-09 19:22:37 -04:00
3e13ac60f1 feat: v1.6.0 — fix service 500, search bar, modal redesign
- Fix 500 error: cast to string before preg_replace
- Search bar to filter services by name/description
- Redesigned service action modal with status badge + colored buttons
- Version 1.6.0
2026-06-09 19:20:18 -04:00
2a29585aa2 Merge pull request 'v1.5.0 — service actions + cleanup' (#29) from feat/android-v1.5.0 into master
Reviewed-on: #29
Reviewed-by: rafaga21 <rafaelminaya20@hotmail.com>
2026-06-09 19:05:07 -04:00
c4277c937f feat: v1.5.0 + service actions + remove duplicate apk
- Services tab: start/stop/restart/reload via dialog
- Backend: POST /api/servers/:id/service-action
- Removed duplicate APK download from dashboard view
- Version bump to 1.5.0
2026-06-09 19:02:41 -04:00