File size: 3,432 Bytes
bad179a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Server Monitor (Python, Linux)

A desktop program that watches Linux machines in detail, keeps their history from seconds to years, analyzes that history with plain statistics (no AI), and fixes common problems automatically. It is a port of the C++/Qt edition to the Python 3 standard library only: the interface is tkinter, and every gauge, chart, tile and table is drawn by hand on a canvas.

## Requirements

- Linux, Python 3.8 or newer with tkinter (`sudo apt install python3-tk` on Debian/Ubuntu). No pip packages.
- The system `ssh` client, only for remote servers.

## Run

```bash
./run.sh          # or: python3 main.py
```

The first start adds "This computer". Closing the window ends the program (there is no tray icon).

## How it connects

- **This machine:** no setup. A small POSIX `sh` script (embedded in `plat.py`) reads `/proc` and `/sys`.
- **SSH:** nothing to install on the server. The same script is sent over your `ssh` client. Keys are recommended (`ssh-copy-id user@host`); a password also works, and a small temporary helper script answers ssh's password prompt.

All calculations happen in the app. Control actions run as the login user; tick **sudo -n** for a server to allow privileged actions (needs passwordless sudo).

## Features

- **Dashboard:** a live card per server (gauges, sparkline, health grade), totals, recent events, search.
- **Server tabs:** Overview, CPU (per core, temperatures, GPUs), Memory, Storage, Network, Processes (signals, priority), Services (start/stop/restart/enable/disable, logs), History, Insights & Autopilot, Alert rules, Console.
- **History:** every sample kept 6 h, 1-minute averages and peaks 30 days, hourly 2 years, daily 20 years; downtime is stored too. Ranges from 1 h to all time, min / average / 95th percentile / peak, CSV export.
- **Analysis (every minute):** disk-full forecast, memory trend, per-process leaks and runaways, failed or flapping services, overload, swap thrashing, anomalies against the same weekday and hour, availability, capacity advice, health score with grade, weekly heatmap.
- **Autopilot:** acts on the findings with cooldowns and a restart limit; **dry run** only reports. Services that were already failed when monitoring started are left alone.
- **Alert rules:** "CPU > 90 % for 60 s → warning → restart a service"; events go to the Events page and to `alerts.log`.

## Data

Everything is stored in `~/.config/ServerMonitorPy` (or `$XDG_CONFIG_HOME/ServerMonitorPy`):

- `servers.json` (mode 600): servers, rules and autopilot settings. Saved SSH passwords are only lightly disguised, not encrypted, so prefer keys.
- `history/<server id>/{raw,minute,hour,day}.bin`: the history tiers.
- `alerts.log`: every alert and action.

The file formats are the same as in the other Server Monitor editions, so files can be copied between them.

## Code

```
main.py      entry point
plat.py      everything Linux-specific: collector script, spawning, frame parser, command tables
metrics.py   one parsed sample + helpers shared by the platform parsers
model.py     configuration, rules, formatting
history.py   history store + analyzer
session.py   ssh/local link, per-server session (rules, autopilot), manager
widgets.py   theme, hand-drawn widgets, small UI builders
tabs.py      server detail tabs
ui.py        dashboard, detail page, add/edit dialog, main window
```

Only `plat.py` differs from the Windows edition.