Add container_stats tool (Gruppe 2); remove rename_container

container_stats(container_name) calls SYNO.Docker.Container/stats,
locates the entry by name (stripping the DSM-added leading slash),
and reports:
  - CPU %  (standard Docker formula: cpu_delta / system_delta * cpus * 100)
  - Memory used / limit  (human-readable)
  - Network I/O rx / tx  (summed across all interfaces)
  - Block I/O read / write  (from io_service_bytes_recursive)

Gracefully handles first-poll (precpu system_cpu_usage absent → 0%).
7 unit tests covering: found, CPU formula, memory format, slash-strip,
not-found, API error, no-precpu fallback.

rename_container removed: DSM Container Manager offers no rename API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-13 18:29:17 +02:00
parent 5edd051830
commit a8da306ce5
3 changed files with 275 additions and 17 deletions
+9 -13
View File
@@ -32,14 +32,14 @@ via Container Manager. Der MCP-Server ist in Claude Desktop aktiv verbunden.
## Aktueller Stand
### Implementierte Tools (14)
### Implementierte Tools (17)
| Kategorie | Tools |
|---|---|
| Projekte | `list_projects`, `get_project_status`, `start_project`, `stop_project`, `redeploy_project` |
| Container | `list_containers`, `get_container_status`, `get_container_logs`, `exec_in_container` |
| Container | `list_containers`, `get_container_status`, `get_container_logs`, `exec_in_container`, `container_stats` |
| Compose | `read_compose`, `update_compose`, `update_image_tag`, `update_env_var` |
| Images | `check_image_updates` |
| Images | `check_image_updates`, `list_images`, `delete_image` |
### Bekannte Bugs
@@ -58,8 +58,8 @@ via Container Manager. Der MCP-Server ist in Claude Desktop aktiv verbunden.
- `pull_image` Image manuell aus Registry ziehen
### Container
- `container_stats` Live CPU/RAM-Verbrauch pro Container
- `rename_container` Container umbenennen
- ~~`container_stats`~~ implementiert
- ~~`rename_container`~~ entfällt (DSM bietet kein Container-Umbenennen)
### Netzwerke
- `list_networks` alle Docker-Netzwerke auflisten
@@ -152,19 +152,15 @@ Implementiere **eine Gruppe nach der anderen**. Commit + Push nach jeder Gruppe,
---
#### Gruppe 2 Container `modules/containers.py` ✦ Prio: mittel
#### Gruppe 2 Container `modules/containers.py` ✦ Prio: mittel ✅ erledigt
**`rename_container`**
- Signatur: `rename_container(container_name: str, new_name: str, confirmed: bool = False) -> str`
- DSM API: `SYNO.Docker.Container` rename (oder Docker Engine API direkt)
- Hinweis nach Erfolg: compose.yml ggf. manuell anpassen (`container_name`)
- Confirmation: **ja**
**`container_stats`**
**`container_stats`**
- Signatur: `container_stats(container_name: str) -> str`
- Ausgabe: CPU %, RAM verwendet/limit, Netzwerk I/O, Block I/O
- Confirmation: nein
**`rename_container`** entfällt (DSM bietet kein Container-Umbenennen)
---
#### Gruppe 3 System `modules/system.py` (neu) ✦ Prio: hoch