Jellyfin: who is watching, and don't update a machine mid-film

New Jellyfin integration (read-only, every 2 minutes): version, restart wanted,
streams and transcoding, failed scheduled tasks, item counts, failed sign-ins.
Monitoring -> Jellyfin page with a peak-streams history, three alerts, /metrics.

When Jellyfin runs on a managed server, an update run asks first if people are
streaming (409 "watching" unless startAnyway), and a patch plan waits up to two
hours for them before updating that server.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-24 22:01:18 +02:00
1 parent 2f082ca5c2
commit 0146eb8bca
38 files changed
+8136 -13

No files matched your search

+30 -2
View File
@@ -23,8 +23,8 @@ what the app actually creates.
|---|---|
| **File** | `DATABASE_PATH`, default `../data/homelab-manager.sqlite` (relative to `server/`; `/app/data/...` in Docker). The folder is created if missing. |
| **Foreign keys** | Switched on for every connection (`PRAGMA foreign_keys = ON`), so the `ON DELETE` rules below are enforced. |
| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0056`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. |
| **Tables** | 68 application tables, plus drizzle's own `__drizzle_migrations`. |
| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0057`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. |
| **Tables** | 70 application tables, plus drizzle's own `__drizzle_migrations`. |
**Not in the database, but beside it in the data folder:** the backups of the database itself (`backups/homelab-manager-….sqlite`, taken daily and on request; see [BACKUP.md](BACKUP.md)), and, only while a restore is waiting or has just happened, `restore-pending.sqlite` / `restore-pending.json` and `restore-result.json`.
@@ -68,6 +68,8 @@ erDiagram
integrations ||--o{ ha_readings : "cascade"
integrations ||--o| ups_state : "cascade"
integrations ||--o{ ups_readings : "cascade"
integrations ||--o| jellyfin_state : "cascade"
integrations ||--o{ jellyfin_readings : "cascade"
users ||--o{ todos : "assignee (set null)"
servers ||--o{ network_server_links : "cascade"
integration_credentials ||--o{ dns_providers : "credential (set null)"
@@ -845,6 +847,31 @@ A UPS at a moment, for the charts: one every five minutes, and every minute whil
| `runtime_seconds` | integer | |
| `on_battery` | bool NOT NULL, default 0 | |
#### `jellyfin_state`
How a Jellyfin (an integration of type `jellyfin`) is right now, one row each, replaced at every read (every two minutes). `integration_id` is the primary key and a foreign key with **cascade**.
| Column | Type | Notes |
|---|---|---|
| `integration_id` | integer PK | |
| `server_name`, `version`, `os` | text | As Jellyfin says. |
| `pending_restart`, `update_available` | bool NOT NULL, default 0 | |
| `streams` | text NOT NULL, default `[]` | JSON: who is streaming what (user, client, device, title, transcoding, paused). |
| `tasks` | text NOT NULL, default `[]` | JSON: the scheduled tasks and how each last ended. |
| `movies`, `series`, `episodes`, `songs` | integer | Item counts; null when not said. |
| `failed_logins_24h` | integer | Null when the activity log could not be read. |
| `updated_at` | text NOT NULL | ISO. |
#### `jellyfin_readings`
How many were streaming, and how many of those were transcoded, at a moment: one every five minutes and at once when either number changes, deleted after 35 days. `integration_id` is a foreign key with **cascade**; (`integration_id`, `at`) is indexed.
| Column | Type | Notes |
|---|---|---|
| `id` | integer PK | |
| `at` | text NOT NULL | ISO. |
| `streams`, `transcodes` | integer NOT NULL | |
#### `service_levels`
A service-level target (Monitoring → Service levels): what a thing is held to, measured over calendar months. No foreign keys: the thing measured is a plain reference, and a target whose subject is removed is shown as having nothing to measure.
@@ -1282,6 +1309,7 @@ are deleted), and `notification_queue` is emptied each time the quiet-hours dige
| `storage_samples` | 400 days (a pool not reported for 30 days is deleted with its readings) |
| `ha_readings` | 35 days |
| `ups_readings` | 35 days |
| `jellyfin_readings` | 35 days |
| `duplicati_runs` | 400 days, and at most 400 per backup job |
| `heartbeat_pings` | 14 days |
| `alert_incidents`, `incident_notes` | 400 days after the incident resolved |