# Server Monitor A Qt 5 / C++17 desktop program for Linux that watches Linux servers in detail, keeps their history from seconds to years, analyzes that history with plain statistics (no AI), and fixes common problems automatically. It uses only Qt plus the system `ssh` program. All charts and gauges are drawn by hand with `QPainter`. ## Build and run ```bash ./build.sh run # build, then start (./build.sh = build only, ./build.sh clean) ``` Qt 5.15 is needed. The script uses the system Qt 5 headers if installed (`qtbase5-dev`); otherwise it uses a local copy in `~/.local/share/qt5-sdk/root`, which needs no root access. `cmake` and `ServerMonitor.pro` (Qt Creator) also work. ## Servers Add or remove servers from the sidebar or the dashboard. There are two ways to connect: - **This machine:** no setup. - **SSH:** nothing to install on the server. The app uses your system `ssh` client. Keys are recommended (`ssh-copy-id user@host`); a password also works, and the app answers ssh's password prompt itself. A small POSIX `sh` script (in `src/core/Platform.cpp`) reads `/proc` and `/sys` on the server. All calculations happen in the app. Control actions run as the login user. To allow privileged actions (restarting services, killing other users' processes, cleanup), tick **sudo -n** for that server; this needs passwordless sudo. ## Features - **Dashboard:** a live card per server (gauges, sparklines, health grade), totals across servers, and recent events. - **Server tabs:** - Overview, CPU (per core, temperatures, GPUs), Memory. - Storage (usage, read/write speed, how busy each disk is), Network (per interface, TCP states). - Processes (terminate, kill, suspend, resume, change priority), Services (start, stop, restart, enable, disable, logs). - History, Insights & Autopilot, Alert rules, and a Console with quick checks, reboot and shut down. - **History:** stored per server in `~/.config/ServerMonitor/ServerMonitor/history/`. - Every sample kept 6 h; 1-minute averages and peaks kept 30 days; hourly kept 2 years; daily kept 20 years. - Downtime is stored too, so availability is known. - The History tab shows 1 h up to all time, with min / average / 95th percentile / peak and CSV export. - **Analysis:** runs every minute using regression, means, standard deviations and percentiles. - Disk-full forecast, steady memory growth, per-process leaks, runaway processes, failing or flapping services, overload, swap thrashing. - Anomalies compared with the same weekday and hour over the last 8 weeks; availability; capacity advice. - A health score (0–100, grade A–F) and a weekly busy-hours heatmap. - **Autopilot:** acts on the findings, each type with its own setting. - Restarts failed services, with a per-hour limit. Services already failed when monitoring started are left alone. - Renices or terminates runaway processes, and handles leaking processes. - Optional disk cleanup (off by default) and anomaly alerts. - Every action has a cooldown and is logged; **dry run** only reports what it would do. - **Alert rules:** for example, "CPU > 90 % for 60 s → warning → restart a service". Events go to the Events page, to desktop notifications and to `alerts.log`. ## Code ``` src/core/Platform.* everything Linux-specific: collector script, its parser, control commands src/core/Model.* config, rules, metrics, formatting src/core/History.* history store + analyzer src/core/Session.* ssh/local link, per-server session (rules, autopilot), manager src/ui/Widgets.* theme, hand-painted widgets, small UI builders src/ui/Tabs.cpp server detail tabs src/ui/Windows.* dashboard, detail page, add/edit dialog, main window ``` The Windows edition (`Server Monitor(cqt-window)`) is the same code with a different `Platform.cpp`. Settings are in `~/.config/ServerMonitor/ServerMonitor/servers.json` (file mode 600). Saved SSH passwords are only lightly disguised, not encrypted, so prefer keys.