From d9083adb5bfee5e7d4e7acaad291a0bd28dd88de Mon Sep 17 00:00:00 2001 From: Bobban Rydh Date: Tue, 27 Oct 2026 20:04:55 +0100 Subject: [PATCH] Sonarr/Radarr/Prowlarr, Hetzner load balancers/floating IPs/certificates, traffic forecast New integration kinds sonarr, radarr and prowlarr (shared adapter and sync, page under Apps -> Media managers): own health findings, stuck downloads, nearly full disks. Hetzner now reads load balancers (target health), floating IPs and certificates, includes them in the cost estimate, and forecasts the month's traffic against the quota. Migrations 0072 and 0073; docs, metrics and tests included. Co-Authored-By: Claude Sonnet 5.5 --- DATABASE.md | 25 +- INTEGRATIONS.md | 11 + README.md | 4 +- ROLES.md | 2 + docs/MONITORING.md | 24 +- docs/PROMETHEUS-GRAFANA.md | 9 +- server/drizzle/0072_fair_shiver_man.sql | 3 + server/drizzle/0073_chilly_silver_surfer.sql | 11 + server/drizzle/meta/0072_snapshot.json | 8013 +++++++++++++++++ server/drizzle/meta/0073_snapshot.json | 8094 ++++++++++++++++++ server/drizzle/meta/_journal.json | 14 + server/src/app.ts | 2 + server/src/db/schema.ts | 24 + server/src/index.ts | 2 + server/src/integrations/arr/adapter.ts | 234 + server/src/integrations/fieldSchemas.ts | 15 + server/src/integrations/hetzner/adapter.ts | 182 +- server/src/integrations/registry.ts | 5 + server/src/routes/arr.ts | 46 + server/src/routes/hetzner.ts | 18 +- server/src/routes/integrations.ts | 4 + server/src/services/alerts.ts | 13 +- server/src/services/arrSync.ts | 227 + server/src/services/healthMonitor.ts | 33 +- server/src/services/hetznerSync.ts | 148 +- server/src/services/maintenance.ts | 4 +- server/src/services/metrics.ts | 38 +- server/test/arr.test.ts | 365 + server/test/hetzner.test.ts | 5 +- server/test/hetznerExtras.test.ts | 390 + web/src/App.tsx | 2 + web/src/api/client.ts | 86 +- web/src/components/HetznerServerCard.tsx | 3 +- web/src/components/WallView.tsx | 3 + web/src/layout/nav.tsx | 2 + web/src/pages/Hetzner.tsx | 115 +- web/src/pages/Media.tsx | 232 + web/src/utils/integrationTypes.ts | 8 +- 38 files changed, 18374 insertions(+), 42 deletions(-) create mode 100644 server/drizzle/0072_fair_shiver_man.sql create mode 100644 server/drizzle/0073_chilly_silver_surfer.sql create mode 100644 server/drizzle/meta/0072_snapshot.json create mode 100644 server/drizzle/meta/0073_snapshot.json create mode 100644 server/src/integrations/arr/adapter.ts create mode 100644 server/src/routes/arr.ts create mode 100644 server/src/services/arrSync.ts create mode 100644 server/test/arr.test.ts create mode 100644 server/test/hetznerExtras.test.ts create mode 100644 web/src/pages/Media.tsx diff --git a/DATABASE.md b/DATABASE.md index 880a7d9..41c7d6a 100644 --- a/DATABASE.md +++ b/DATABASE.md @@ -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` … `0071`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. | -| **Tables** | 83 application tables, plus drizzle's own `__drizzle_migrations`. | +| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0073`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. | +| **Tables** | 84 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`. @@ -76,6 +76,7 @@ erDiagram integrations ||--o{ dockhand_vulnerabilities : "cascade" integrations ||--o| hetzner_state : "cascade" integrations ||--o| fragnet_state : "cascade" + integrations ||--o| arr_state : "cascade" integrations ||--o{ speedtest_results : "cascade" integrations ||--o| netbox_state : "cascade" integrations ||--o| n8n_state : "cascade" @@ -960,7 +961,8 @@ How a Hetzner Cloud project (an integration of type `hetzner`; a token belongs t | `integration_id` | integer PK | | | `servers` | text NOT NULL, default `[]` | JSON: each server as read (status, type, location, addresses, traffic this month and included, rescue mode, backup window, monthly price) plus what the app has seen of it between reads: `lastRunningAt`, `statusSince`, `rescueSince`. Hetzner does not say when a server went off; these are the times of the reads that showed it. | | `volumes`, `images` | text | JSON; the volumes, and the snapshots and backups. **Null when they could not be asked** — which is not the same as none. | -| `cost` | text | JSON: the monthly estimate at list prices including VAT (currency, servers, backups, volumes, snapshots, IPs, total). Null when the price list could not be read. | +| `cost` | text | JSON: the monthly estimate at list prices including VAT (currency, servers, backups, volumes, snapshots, IPs, load balancers, floating IPs, total). Null when the price list could not be read. | +| `load_balancers`, `floating_ips`, `certificates` | text | JSON: each load balancer with the health of its targets, each floating IP and what it points at, each certificate with when it ends. **Null when they could not be asked.** (Migration `0072`.) | | `updated_at` | text NOT NULL | ISO. | How the last read went is kept in `settings`, key `_internal:hetznerSync`. @@ -977,6 +979,23 @@ How a Fragnet game panel account (an integration of type `fragnet`; an API key b How the last read went is kept in `settings`, key `_internal:fragnetSync`. +#### `arr_state` + +How a Sonarr, Radarr or Prowlarr (an integration of type `sonarr`, `radarr` or `prowlarr`) is right now, one row each, replaced at every read (every five minutes). `integration_id` is the primary key and a foreign key with **cascade**. There is no history: what is stored is the last good read. + +| Column | Type | Notes | +|---|---|---| +| `integration_id` | integer PK | | +| `version` | text | | +| `health` | text NOT NULL, default `[]` | JSON: what its own checks found (source, type, message). | +| `queue` | text | JSON `{ total, items }`: how many downloads there are and the first hundred (title, status, how it is judged, what it says is wrong, size, when it was added, client, indexer). **Null when it could not be read** — and always for Prowlarr, which has none. | +| `disks` | text | JSON: path, free and total bytes; null when it could not be read. | +| `missing` | integer | Wanted items with no file (Sonarr, Radarr); null when not read. | +| `indexers` | text | JSON, Prowlarr only: each indexer and, if Prowlarr has switched it off after failures, until when. | +| `updated_at` | text NOT NULL | ISO. | + +How the last read went is kept in `settings`, key `_internal:arrSync`. + #### `n8n_state` How an n8n (an integration of type `n8n`) is right now, one row each, replaced at every read (every five minutes). `integration_id` is the primary key and a foreign key with **cascade**. diff --git a/INTEGRATIONS.md b/INTEGRATIONS.md index 38b411d..18c8406 100644 --- a/INTEGRATIONS.md +++ b/INTEGRATIONS.md @@ -392,6 +392,15 @@ osTicket's API cannot close a ticket, so this is the one place in the app that * name, not by its text, which is in the language Nextcloud is set to — gives the alert above and the *Background jobs* line on the page. Any other of those checks that reports an **error** is one alert, and ones that report a **warning** (HTTP headers, a PHP setting …) are only listed on the page, as in Nextcloud's own admin overview. **Before Nextcloud 28** there is no such page: cron and the checks are then *not known* (and say so, never *fine*). The same read gives the version Nextcloud itself says is available, shown on the page. With **Nextcloud AIO** the admin pages are the mastercontainer's, but the Nextcloud behind it is an ordinary one and is read the same way (use its own address, not the AIO admin address). +### Sonarr, Radarr and Prowlarr + +- **Config fields:** the application's **URL** and its **API key** (in the application: Settings → General → Security → API Key; stored encrypted), and *Allow self-signed certificate* if it is on HTTPS with its own certificate. Add each application as its own integration, as the kind it is — the *Test* button says if the address turns out to be another one. The key is sent as `X-Api-Key`; the app only ever sends GET requests. +- **Required access:** the application's address reachable from the app. Sonarr and Radarr answer under `/api/v3`, Prowlarr under `/api/v1`. A read is five to six requests, every five minutes. +- **What it does:** every **five minutes** each application is read — its version, what its own checks found (`/health`), its **download queue** (`/queue`: the first 100, and how many there are), its **disks** (`/diskspace`), for Sonarr and Radarr how many **wanted** items have no file (`/wanted/missing`), and for Prowlarr its **indexers** and which it has switched off after failures (`/indexer`, `/indexerstatus`). **Apps → Media managers** shows them. Nothing is searched, grabbed, removed or changed. + - **Alerts** (sources *Sonarr*, *Radarr*, *Prowlarr*; held back by maintenance on the integration): what the application **says is wrong** with itself (a finding of type warning or error — a download client that cannot be reached, a root folder gone, indexers unavailable; a *notice*, such as an update being available, is shown but not raised); **downloads that are stuck** (in the queue for two hours or more and judged warning or error, failed, or blocked from importing — one alert for the lot, naming the first three and why); a **disk nearly full** (under 10% free, critical under 5%; folders on one disk count once, and a disk under 2 GB is not a media disk). See [MONITORING.md](docs/MONITORING.md#media-managers-sonarr-radarr-prowlarr). + - If an application cannot be read for 20 minutes its alerts are neither raised nor cleared, the Alerts page says it could not check, and the integration is raised as failing like any other. A part that could not be read (the queue, say) is shown as *could not be read*, never as empty. + - `/metrics` has `homelab_arr_health_issues`, `homelab_arr_queue_items`, `homelab_arr_queue_stuck_items`, `homelab_arr_wanted_missing` and `homelab_arr_disk_free_bytes`. +- **Not verified against live installs** — the endpoints and fields are as the applications' published OpenAPI files and source have them (HealthResource, QueueResource, DiskSpaceResource, IndexerStatusResource), and the reader is tried against pretend ones. A finding is raised under a key made from the check and its words (numbers left out), so a finding whose wording changes is raised anew. Lidarr, Readarr and Bazarr are not read. ### Hetzner Cloud - **Config fields:** the project's **API token** (Hetzner Console → the project → Security → API tokens → *Generate API token*; stored encrypted). **Read** permission is enough — and recommended: the app only ever sends GET requests. A token belongs to **one project**, so add one integration for each project you want to watch. @@ -399,6 +408,8 @@ osTicket's API cannot close a ticket, so this is the one place in the app that * - **What it does:** every **five minutes** the project's servers, volumes, snapshots and backups, primary IPs and Hetzner's price list are read and stored. The **Hetzner Cloud** page shows them with a monthly cost estimate; a server's own page gets a card when it is one of them (matched by address, else by name). - **Alerts** (source *Hetzner*; held back by maintenance on the integration): a server that **was running and is off** (warning; left alone after a week), one **stuck** migrating or rebuilding for half an hour, **traffic** at 80% of the month's quota (critical at 100%), **rescue mode** left on for an hour, and **backups** enabled but late (the same limit as Proxmox guests' backups, 48 hours by default). See [MONITORING.md](docs/MONITORING.md#hetzner-cloud). - If Hetzner cannot be read for 20 minutes its alerts are neither raised nor cleared, the Alerts page says it could not check, and the integration is raised as failing like any other. A list that could not be asked (the volumes, say) is shown as *could not be read*, never as empty. + - **Load balancers, floating IPs and certificates** are read with the rest (a list that cannot be asked is shown as *could not be read*, never as none): the Hetzner page lists each **load balancer** with the health of its targets, each **floating IP** and what it points at, and each **certificate** with when it ends. Their prices (a load balancer's type, a floating IP's kind and place) are now in the cost estimate. Alerts: a **load balancer with an unhealthy target** (warning; critical when none of its targets is healthy), a **certificate** that is in use and ends within 14 days (critical within 3, or past its end) or that Hetzner could not issue or renew, and a **floating IP that points at no server** (it is billed all the same). A certificate nothing uses is not raised. + - **Traffic forecast:** from the month's traffic the app writes down about every six hours it works out how the month is going — by the last week's rate, or, with too little of it, by the month's average (after three days) — and warns, below the 80% alert, when a server is **on course to pass its quota before the month ends**: "at this rate web will pass its 20.0 TB traffic quota on 24 June". The page shows the date, or what the month will come to, under each server's traffic bar. The month is the calendar month in UTC; a counter that goes down starts the history over. - `/metrics` has `homelab_hetzner_server_running`, `homelab_hetzner_traffic_outgoing_bytes`, `homelab_hetzner_traffic_included_bytes` and `homelab_hetzner_monthly_cost`. - **Not verified against a live project** — the endpoints (`/servers`, `/volumes`, `/images?type=snapshot` and `type=backup`, `/primary_ips`, `/pricing`) and their fields are as Hetzner's published OpenAPI file has them, and the reader is tried against a pretend server. **Traffic** is read as bytes and shown in binary units (Hetzner's 20 TB is 20 TiB); a server's *included* traffic and the *outgoing* traffic of the current billing month come from the server itself. The **cost** is the list price including VAT (the `gross` prices): check it against Hetzner's invoice the first time. Dedicated (Robot) servers and Hetzner Storage Boxes are a different API and are not read. diff --git a/README.md b/README.md index e41d43c..5dff9c8 100644 --- a/README.md +++ b/README.md @@ -535,10 +535,12 @@ second in a row), an overdue one (2 days by default, per job) a warning (critica **Nextcloud** (Apps → Nextcloud). Add a Nextcloud integration (its address; an administrator's app password adds more) and the app tells you when people **cannot use it**: **critical** when its database needs upgrading, a warning when it is stuck in **maintenance mode**, and a warning (critical under 5 GB) when the **data disk is low**. The page also shows the users, the files and the app updates waiting. Whether its **background jobs (cron) are running** is read from Nextcloud's own setup checks (Nextcloud 28 or later), and a warning is raised when they are not — a stopped cron would otherwise go unnoticed for weeks. See INTEGRATIONS.md and docs/MONITORING.md. -**Hetzner Cloud** (Infrastructure → Hetzner Cloud). Add a project's read-only API token and the app lists its servers with their status, this month's traffic against the quota, backups, volumes and snapshots, and roughly what it costs a month. It warns when a server that was running is **off**, when one has used **80% of its traffic** (critical at 100%), when **rescue mode** is left on (the next reboot would not come back up), and when **backups** are enabled but late. A server that is also one the app knows by its agent gets a Hetzner card on its own page. Nothing at Hetzner is ever changed. See INTEGRATIONS.md and docs/MONITORING.md. +**Hetzner Cloud** (Infrastructure → Hetzner Cloud). Add a project's read-only API token and the app lists its servers with their status, this month's traffic against the quota, backups, volumes and snapshots, and roughly what it costs a month. It warns when a server that was running is **off**, when one has used **80% of its traffic** (critical at 100%), when **rescue mode** is left on (the next reboot would not come back up), and when **backups** are enabled but late. A server that is also one the app knows by its agent gets a Hetzner card on its own page. It also lists **load balancers** (with the health of their targets), **floating IPs** and **certificates**, warns when a target is unhealthy, a certificate is about to end or a floating IP points at nothing, and **forecasts the month's traffic** ("at this rate web will pass its quota on 24 June"). Nothing at Hetzner is ever changed. See INTEGRATIONS.md and docs/MONITORING.md. **Game servers** (Infrastructure → Game servers, for Fragnet's game panel). Add an account's API key and the app lists its game servers: the game, the IP addresses and ports (click one to copy it), whether each is running, its memory and disk against the plan, its backups, schedules and databases. It warns when a server's **newest backup is late** (7 days by default, or none at all — a server can be left out by name) and when **disk or memory is nearly full** (90% by default); a server that is merely stopped is not an alert, since game servers are often stopped on purpose. Operators can **start, stop, restart and kill** a server from the page (asked first, written to the audit log); nothing else at Fragnet is changed. Fragnet's panel is a fork of Pterodactyl, so the same integration reads any Pterodactyl panel (give its address). See INTEGRATIONS.md and docs/MONITORING.md. +**Media managers** (Apps → Media managers). Add Sonarr, Radarr and Prowlarr with their address and API key and the app shows, for each, what the application says is wrong with itself, its download queue (what is stuck or failed, and why), the disks it fills, how many wanted items have no file and, for Prowlarr, which indexers have failed. It warns when an application reports a **warning or error** (a download client that cannot be reached, indexers switched off), when **downloads have been stuck for two hours**, and when a **disk is nearly full**. Nothing is searched, grabbed or changed. See INTEGRATIONS.md and docs/MONITORING.md. + **Speedtest** (Monitoring → Speedtest). Add a Speedtest Tracker integration (its address and an API token with the *results:read* ability) and the app charts how fast the internet has been — download, upload and ping over up to 90 days — and, if you tell it what the line is sold at, warns when **the middle of the last three tests is under 60%** of it, and when **the tests keep failing**. One slow test is not an alert. The app never starts a test. On a status page the integration reads as the internet. See INTEGRATIONS.md and docs/MONITORING.md. **NetBox** (Monitoring → NetBox). Add a NetBox integration (its address and a read-only token): a warning when **no background worker** is running (they are a separate container in the Docker image, and can be down while the pages load), and a list on the page of **the servers you run that have no address in NetBox**. That list is diff --git a/ROLES.md b/ROLES.md index 141e899..5dd6d3d 100644 --- a/ROLES.md +++ b/ROLES.md @@ -32,6 +32,7 @@ page's own top-level link. | **Apps** | | | | | | Home Assistant | `/home-assistant` | ✅ | ✅ | ✅ | | Jellyfin | `/jellyfin` | ✅ | ✅ | ✅ | +| Media managers | `/media` | ✅ | ✅ | ✅ | | Immich | `/immich` | ✅ | ✅ | ✅ | | Paperless-ngx | `/paperless` | ✅ | ✅ | ✅ | | Nextcloud | `/nextcloud` | ✅ | ✅ | ✅ | @@ -159,6 +160,7 @@ even further, to admin only: - **Prometheus** (Monitoring → Prometheus): everyone signed in sees the targets, what is down and the alerts firing; adding one (its address, and a token if it needs one) is an administrator's job, like any integration. - **Authentik** (Apps → Authentik): everyone signed in sees the outposts, what runs out and the failed-sign-in count (the names of tokens and certificates, not their values); adding one (its address and API token) is an administrator's job, like any integration. - **Jellyfin** (Apps → Jellyfin): everyone signed in sees who is streaming and what is wrong; adding one (its address and API key) is an administrator's job, like any integration. Starting an update run on a server people are streaming from needs `startAnyway` — the update drawer asks (operators). +- **Media managers** (Apps → Media managers, for Sonarr, Radarr and Prowlarr): everyone signed in sees what each says is wrong, its queue, disks and indexers; adding one (its API key) is an administrator's job, like any integration. Nothing on the page changes anything in them. - **Duplicati** (Backups → Duplicati): everyone signed in sees every backup and how it went; setting how often one is expected, muting it and forgetting it need operator; adding a machine (which makes an address that can write to this app) and removing one are administrators'. Reports arrive on a secret address with no sign-in: the token is the access. - **Restore tests**: everyone sees them on the Backup coverage page; recording one needs operator; removing one is administrator-only. - **Change log**: operators and administrators (it is made from the audit log, which has the same readers). diff --git a/docs/MONITORING.md b/docs/MONITORING.md index 90fdc8b..6e9da45 100644 --- a/docs/MONITORING.md +++ b/docs/MONITORING.md @@ -16,6 +16,7 @@ This page explains what Homelab Manager watches, how often, how a problem become - [Nextcloud](#nextcloud) - [Hetzner Cloud](#hetzner-cloud) - [Game servers (Fragnet)](#game-servers-fragnet) +- [Media managers](#media-managers-sonarr-radarr-prowlarr) - [Speedtest](#speedtest) - [NetBox](#netbox) - [n8n](#n8n) @@ -142,6 +143,7 @@ Every threshold here is a default; where it can be changed, the place is named. | **Docker updates** | A container image has a newer version | | Settings → Notifications | | **Nextcloud can't be used / disk low** | The database needs upgrading (critical), maintenance mode is on, or little room is left for the data (critical under 5 GB) | on, with the integration | Nextcloud page; [below](#nextcloud) | | **Hetzner server off / traffic / rescue / backup** | A Hetzner Cloud server that was running is off, is stuck migrating or rebuilding, has used 80% of its month's traffic (critical at 100%), has rescue mode left on, or has backups enabled but none recent | on, with the integration | Hetzner page; [below](#hetzner-cloud) | +| **Sonarr / Radarr / Prowlarr** | An application reports a health warning or error, has downloads stuck for two hours, or a disk under 10% free | on, with the integration | Media managers page; [below](#media-managers-sonarr-radarr-prowlarr) | | **Game server backup / disk / memory** | A Fragnet game server's newest backup is older than the limit (7 days) or none, its disk is over 90% of the plan (critical from 98%), or its memory is over 90% while it runs | on, with the integration | Game servers page; [below](#game-servers-fragnet) | | **Internet slow / speed tests failing** | The middle of the last three speed tests is under the share you set of what the line is sold at (only with those numbers given), or the last three tests all failed | on, with the integration | Speedtest page; [below](#speedtest) | | **NetBox has no worker** | No background worker is running | on, with the integration | NetBox page; [below](#netbox) | @@ -263,13 +265,33 @@ An integration of type *Hetzner Cloud* ([INTEGRATIONS.md](../INTEGRATIONS.md#het | **Traffic** | A server has sent **80%** of its included traffic for the month; at **100%** it is critical (the excess is billed) | warning; critical at 100% | | **Rescue mode left on** | Rescue mode has been switched on for **an hour** without a reboot — the next reboot (a kernel update, say) would come up in the rescue system and the server would not come back | warning | | **Backups late** | A server has backups enabled and the newest is older than the *backup older than* limit (48 hours by default — the same setting as for Proxmox guests; 0 turns it off), or none has been made and the server is older than that | warning | +| **Traffic forecast** | A server is **on course to pass its included traffic before the month ends** (by the last week's rate, or the month's average after three days) while it has used under 80% — the alert says on which day. Not raised from 80% on: the traffic alert covers that | warning | +| **Load balancer unhealthy** | A load balancer has a target Hetzner judges unhealthy; critical when none of its targets is healthy | warning; critical when all | +| **Certificate ending** | A certificate that is in use ends within **14 days** (critical within 3, or past its end), or Hetzner could not issue or renew a managed one. A certificate nothing uses is not raised | warning; critical within 3 days | +| **Floating IP unattached** | A floating IP points at no server — it is billed all the same | warning | Hetzner does not say when a server went off or when rescue mode was switched on, so "since when" is **when the app first saw it** in a read. Maintenance on the integration holds the alerts; a reading older than 20 minutes is not believed (they are neither raised nor cleared, and the Alerts page says it could not check). Snapshots, volumes (including ones attached to no server, which are billed all the same) and the cost are shown, not alerted. -**The cost** is an estimate from Hetzner's own price list, including VAT: the servers, their backups (a percentage of the server's price), volumes, snapshots and primary IPs. It leaves out load balancers, floating IPs and traffic over the quota, so it is a floor, not a bill. +**The cost** is an estimate from Hetzner's own price list, including VAT: the servers, their backups (a percentage of the server's price), volumes, snapshots, primary IPs, load balancers and floating IPs. It leaves out traffic over the quota, so it is a floor, not a bill. + +**The traffic forecast** is made from the month's outgoing traffic, written down about every six hours for two weeks: the rate of the last week (at least two days of it) or, with too little, the month's average so far (after three days). It assumes the month is the calendar month in UTC — not checked against a live project — and a counter that goes down starts the history over. The page shows under each server's traffic bar either the day the quota is passed or what the month is on course to come to. + +**Load balancers, floating IPs and certificates** are listed on the Hetzner page — a load balancer with how many of its targets are healthy, a floating IP with the server it points at, a certificate with when it ends (and the ones nothing uses) — and their prices are in the cost estimate. `/metrics` has each load balancer's unhealthy targets, each certificate's end and each server's forecast month. **On a server's page**, a *Hetzner Cloud* card appears when one of the project's servers is that server — matched by its public or private address, else by name — with its status, type, newest backup and traffic. A Hetzner server with no agent is listed as *not in the app's servers*. `/metrics` has `homelab_hetzner_server_running`, `homelab_hetzner_traffic_outgoing_bytes`, `homelab_hetzner_traffic_included_bytes` and `homelab_hetzner_monthly_cost`. +## Media managers (Sonarr, Radarr, Prowlarr) + +An integration of type *Sonarr*, *Radarr* or *Prowlarr* ([INTEGRATIONS.md](../INTEGRATIONS.md#sonarr-radarr-and-prowlarr)) is read every five minutes, and **Apps → Media managers** shows, for each: what the application says is wrong with itself, its download queue (the stuck ones first, with why), its disks, how many wanted items have no file (Sonarr, Radarr) and, for Prowlarr, which indexers it has switched off after failures. Nothing is searched, grabbed or changed. + +| Alert | When | Severity | +|---|---|---| +| **It says it is unwell** | One of the application's own health checks is a **warning** or an **error** (a download client that cannot be reached, a root folder gone, indexers unavailable…). The alert quotes it. A *notice* — an update being available — is shown on the page, not raised | warning | +| **Downloads stuck** | Downloads that have been in the queue for **two hours or more** and are judged warning or error by the application, have failed, or are blocked from importing. One alert for all of an application's, naming the first three, how long the oldest has been there, and the reason it gives | warning | +| **Disk nearly full** | A disk the application uses has under **10%** free, critical under 5%. Folders on one disk count as one (the same size and free space), and a disk under 2 GB is not a media disk | warning; critical under 5% | + +Maintenance on the integration holds the alerts; a reading older than 20 minutes is not believed (they are neither raised nor cleared, and the Alerts page says it could not check). A finding is raised under a key made from the check and its words with the numbers left out, so "3 indexers unavailable" becoming "4" is the same alert, and different words are a new one. + ## Game servers (Fragnet) An integration of type *Fragnet game servers* ([INTEGRATIONS.md](../INTEGRATIONS.md#fragnet-game-servers)) is one account on Fragnet's game panel (a Pterodactyl fork), read every five minutes, and **Infrastructure → Game servers** shows its servers: the game, every address and port, whether it runs, memory and disk against the plan, the newest backup, and (opened) the backups, schedules and SFTP address. Operators can start, stop, restart and kill a server there. diff --git a/docs/PROMETHEUS-GRAFANA.md b/docs/PROMETHEUS-GRAFANA.md index 20f0d7c..a16e052 100644 --- a/docs/PROMETHEUS-GRAFANA.md +++ b/docs/PROMETHEUS-GRAFANA.md @@ -305,7 +305,14 @@ All gauges. The same table is checked by a test against what `/metrics` really s | `homelab_speedtest_ping_seconds` | `name` | The ping of that test, in seconds. | | `homelab_hetzner_server_running` | `project`, `server` | 1 if the Hetzner Cloud server is running, else 0. | | `homelab_hetzner_traffic_outgoing_bytes`, `homelab_hetzner_traffic_included_bytes` | `project`, `server` | This month's outgoing traffic of a Hetzner Cloud server, and what its type includes per month (bytes). | -| `homelab_hetzner_monthly_cost` | `project`, `currency` | The estimated monthly cost of a Hetzner Cloud project at list prices, including VAT (an estimate: no load balancers, floating IPs or traffic over the quota). | +| `homelab_hetzner_monthly_cost` | `project`, `currency` | The estimated monthly cost of a Hetzner Cloud project at list prices, including VAT (an estimate: it has the load balancers and floating IPs, not traffic over the quota). | +| `homelab_hetzner_traffic_forecast_bytes` | `project`, `server` | What a Hetzner Cloud server's outgoing traffic is forecast to come to by the end of the month; left out when there is too little to say. | +| `homelab_hetzner_load_balancer_unhealthy_targets` | `project`, `load_balancer` | How many targets of a Hetzner Cloud load balancer are unhealthy. | +| `homelab_hetzner_certificate_expiry_timestamp_seconds` | `project`, `certificate` | When a Hetzner Cloud certificate ends, in seconds since 1970. | +| `homelab_arr_health_issues` | `app`, `name` | How many warnings or errors Sonarr, Radarr or Prowlarr reports about itself. | +| `homelab_arr_queue_items`, `homelab_arr_queue_stuck_items` | `app`, `name` | The downloads in the queue of Sonarr or Radarr, and how many are stuck (judged wrong, failed or blocked for two hours or more). | +| `homelab_arr_wanted_missing` | `app`, `name` | Wanted items Sonarr or Radarr has no file for. | +| `homelab_arr_disk_free_bytes` | `app`, `name`, `path` | Free space of a disk Sonarr, Radarr or Prowlarr uses. | | `homelab_fragnet_server_running` | `account`, `server`, `game` | 1 if the Fragnet game server is running, else 0. | | `homelab_fragnet_disk_used_bytes`, `homelab_fragnet_disk_limit_bytes` | `account`, `server`, `game` | The disk a Fragnet game server uses, and the disk its plan allows (left out when unlimited). | | `homelab_fragnet_memory_used_bytes`, `homelab_fragnet_memory_limit_bytes` | `account`, `server`, `game` | The memory a Fragnet game server uses (0 while stopped), and its limit (left out when unlimited). | diff --git a/server/drizzle/0072_fair_shiver_man.sql b/server/drizzle/0072_fair_shiver_man.sql new file mode 100644 index 0000000..95114ad --- /dev/null +++ b/server/drizzle/0072_fair_shiver_man.sql @@ -0,0 +1,3 @@ +ALTER TABLE `hetzner_state` ADD `load_balancers` text;--> statement-breakpoint +ALTER TABLE `hetzner_state` ADD `floating_ips` text;--> statement-breakpoint +ALTER TABLE `hetzner_state` ADD `certificates` text; \ No newline at end of file diff --git a/server/drizzle/0073_chilly_silver_surfer.sql b/server/drizzle/0073_chilly_silver_surfer.sql new file mode 100644 index 0000000..1c5edef --- /dev/null +++ b/server/drizzle/0073_chilly_silver_surfer.sql @@ -0,0 +1,11 @@ +CREATE TABLE `arr_state` ( + `integration_id` integer PRIMARY KEY NOT NULL, + `version` text, + `health` text DEFAULT '[]' NOT NULL, + `queue` text, + `disks` text, + `missing` integer, + `indexers` text, + `updated_at` text NOT NULL, + FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade +); diff --git a/server/drizzle/meta/0072_snapshot.json b/server/drizzle/meta/0072_snapshot.json new file mode 100644 index 0000000..991f193 --- /dev/null +++ b/server/drizzle/meta/0072_snapshot.json @@ -0,0 +1,8013 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "76deb0f5-470b-48ce-b0ff-e8bb864f893c", + "prevId": "c7059fb7-2cc1-4ac5-ad25-61cafa79cd91", + "tables": { + "alert_acks": { + "name": "alert_acks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_name": { + "name": "assignee_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "acked_by": { + "name": "acked_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "acked_at": { + "name": "acked_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "until": { + "name": "until", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "alert_acks_key_idx": { + "name": "alert_acks_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "alert_acks_assignee_user_id_users_id_fk": { + "name": "alert_acks_assignee_user_id_users_id_fk", + "tableFrom": "alert_acks", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_incidents": { + "name": "alert_incidents", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "peak_severity": { + "name": "peak_severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_name": { + "name": "target_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "caused_by": { + "name": "caused_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "opened_at": { + "name": "opened_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "missing_since": { + "name": "missing_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "escalated_step": { + "name": "escalated_step", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "escalated_at": { + "name": "escalated_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_incidents_key_idx": { + "name": "alert_incidents_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": false + }, + "alert_incidents_opened_idx": { + "name": "alert_incidents_opened_idx", + "columns": [ + "opened_at" + ], + "isUnique": false + }, + "alert_incidents_target_idx": { + "name": "alert_incidents_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_rules": { + "name": "alert_rules", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mount": { + "name": "mount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "operator": { + "name": "operator", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'above'" + }, + "threshold": { + "name": "threshold", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "for_minutes": { + "name": "for_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'warning'" + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_snoozes": { + "name": "alert_snoozes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_id": { + "name": "alert_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "condition_key": { + "name": "condition_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "until": { + "name": "until", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snoozed_by": { + "name": "snoozed_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snoozed_at": { + "name": "snoozed_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'snooze'" + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_snoozes_alert_idx": { + "name": "alert_snoozes_alert_idx", + "columns": [ + "alert_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_tickets": { + "name": "alert_tickets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "seen_count": { + "name": "seen_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_number": { + "name": "ticket_number", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "grouped": { + "name": "grouped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ticketed_at": { + "name": "ticketed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cleared_at": { + "name": "cleared_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_closed_at": { + "name": "ticket_closed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_closed_by": { + "name": "ticket_closed_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_tickets_key_idx": { + "name": "alert_tickets_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": false + } + }, + "foreignKeys": { + "alert_tickets_integration_id_integrations_id_fk": { + "name": "alert_tickets_integration_id_integrations_id_fk", + "tableFrom": "alert_tickets", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "api_tokens": { + "name": "api_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "api_tokens_token_hash_unique": { + "name": "api_tokens_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": { + "api_tokens_user_id_users_id_fk": { + "name": "api_tokens_user_id_users_id_fk", + "tableFrom": "api_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "assets": { + "name": "assets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "serial": { + "name": "serial", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purchase_date": { + "name": "purchase_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purchase_price": { + "name": "purchase_price", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warranty_until": { + "name": "warranty_until", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "end_of_support": { + "name": "end_of_support", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "replacement_cost": { + "name": "replacement_cost", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "rack_unit": { + "name": "rack_unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "power_watts": { + "name": "power_watts", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "audit_log": { + "name": "audit_log", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_label": { + "name": "actor_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "audit_log_actor_user_id_users_id_fk": { + "name": "audit_log_actor_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "authentik_state": { + "name": "authentik_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "outdated": { + "name": "outdated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "workers": { + "name": "workers", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "outposts": { + "name": "outposts", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "certificates": { + "name": "certificates", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "tokens": { + "name": "tokens", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "failed_logins_24h": { + "name": "failed_logins_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config_errors_24h": { + "name": "config_errors_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_config_error": { + "name": "last_config_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "authentik_state_integration_id_integrations_id_fk": { + "name": "authentik_state_integration_id_integrations_id_fk", + "tableFrom": "authentik_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "consistency_ignores": { + "name": "consistency_ignores", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "consistency_ignores_key_unique": { + "name": "consistency_ignores_key_unique", + "columns": [ + "key" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "cost_items": { + "name": "cost_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Other'" + }, + "renews_on": { + "name": "renews_on", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dependencies": { + "name": "dependencies", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "from_type": { + "name": "from_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_id": { + "name": "from_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_type": { + "name": "to_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_id": { + "name": "to_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "dependencies_edge_idx": { + "name": "dependencies_edge_idx", + "columns": [ + "from_type", + "from_id", + "to_type", + "to_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "diag_log": { + "name": "diag_log", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "operation": { + "name": "operation", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "latency_ms": { + "name": "latency_ms", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_providers": { + "name": "dns_providers", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_type": { + "name": "provider_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "dns_providers_credential_id_integration_credentials_id_fk": { + "name": "dns_providers_credential_id_integration_credentials_id_fk", + "tableFrom": "dns_providers", + "tableTo": "integration_credentials", + "columnsFrom": [ + "credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_records_cache": { + "name": "dns_records_cache", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_id": { + "name": "provider_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "record_id": { + "name": "record_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ttl": { + "name": "ttl", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxied": { + "name": "proxied", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "dns_records_cache_provider_id_dns_providers_id_fk": { + "name": "dns_records_cache_provider_id_dns_providers_id_fk", + "tableFrom": "dns_records_cache", + "tableTo": "dns_providers", + "columnsFrom": [ + "provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_zones_cache": { + "name": "dns_zones_cache", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_id": { + "name": "provider_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_name": { + "name": "zone_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "synced_at": { + "name": "synced_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "dns_zones_cache_provider_zone_idx": { + "name": "dns_zones_cache_provider_zone_idx", + "columns": [ + "provider_id", + "zone_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "dns_zones_cache_provider_id_dns_providers_id_fk": { + "name": "dns_zones_cache_provider_id_dns_providers_id_fk", + "tableFrom": "dns_zones_cache", + "tableTo": "dns_providers", + "columnsFrom": [ + "provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dockhand_vulnerabilities": { + "name": "dockhand_vulnerabilities", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_id": { + "name": "environment_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_name": { + "name": "environment_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "critical": { + "name": "critical", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "high": { + "name": "high", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "medium": { + "name": "medium", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "low": { + "name": "low", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images_scanned": { + "name": "images_scanned", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_images": { + "name": "total_images", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "findings": { + "name": "findings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "dockhand_vulnerabilities_integration_id_integrations_id_fk": { + "name": "dockhand_vulnerabilities_integration_id_integrations_id_fk", + "tableFrom": "dockhand_vulnerabilities", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "dockhand_vulnerabilities_integration_id_environment_id_pk": { + "columns": [ + "integration_id", + "environment_id" + ], + "name": "dockhand_vulnerabilities_integration_id_environment_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "domains": { + "name": "domains", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'manual'" + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "registrar": { + "name": "registrar", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lookup_source": { + "name": "lookup_source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_ok_at": { + "name": "last_checked_ok_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "domains_name_unique": { + "name": "domains_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_backups": { + "name": "duplicati_backups", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "source_id": { + "name": "source_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_report_at": { + "name": "last_report_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_result": { + "name": "last_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_begin": { + "name": "last_begin", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_end": { + "name": "last_end", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_seconds": { + "name": "duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "examined_files": { + "name": "examined_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_files": { + "name": "added_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "modified_files": { + "name": "modified_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deleted_files": { + "name": "deleted_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warnings": { + "name": "warnings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "errors": { + "name": "errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "expected_hours": { + "name": "expected_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 48 + }, + "alert": { + "name": "alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "duplicati_backups_name_idx": { + "name": "duplicati_backups_name_idx", + "columns": [ + "source_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "duplicati_backups_source_id_duplicati_sources_id_fk": { + "name": "duplicati_backups_source_id_duplicati_sources_id_fk", + "tableFrom": "duplicati_backups", + "tableTo": "duplicati_sources", + "columnsFrom": [ + "source_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_runs": { + "name": "duplicati_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "backup_id": { + "name": "backup_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_seconds": { + "name": "duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "files_changed": { + "name": "files_changed", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warnings": { + "name": "warnings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "errors": { + "name": "errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "duplicati_runs_idx": { + "name": "duplicati_runs_idx", + "columns": [ + "backup_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "duplicati_runs_backup_id_duplicati_backups_id_fk": { + "name": "duplicati_runs_backup_id_duplicati_backups_id_fk", + "tableFrom": "duplicati_runs", + "tableTo": "duplicati_backups", + "columnsFrom": [ + "backup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_sources": { + "name": "duplicati_sources", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_report_at": { + "name": "last_report_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "duplicati_sources_token_hash_unique": { + "name": "duplicati_sources_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_checks": { + "name": "endpoint_checks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expect_status": { + "name": "expect_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "insecure": { + "name": "insecure", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "value_path": { + "name": "value_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_op": { + "name": "value_op", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_expected": { + "name": "value_expected", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_unit": { + "name": "value_unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "header_name": { + "name": "header_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "header_value": { + "name": "header_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_value": { + "name": "last_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "interval_minutes": { + "name": "interval_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 5 + }, + "timeout_seconds": { + "name": "timeout_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "failures_before_alert": { + "name": "failures_before_alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 2 + }, + "warn_days": { + "name": "warn_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 14 + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_ok": { + "name": "last_ok", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_message": { + "name": "last_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_response_ms": { + "name": "last_response_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cert_expires_at": { + "name": "cert_expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_change_at": { + "name": "last_change_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_daily": { + "name": "endpoint_daily", + "columns": { + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "day": { + "name": "day", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total": { + "name": "total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_sum": { + "name": "ms_sum", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_count": { + "name": "ms_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "endpoint_daily_check_id_endpoint_checks_id_fk": { + "name": "endpoint_daily_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_daily", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "endpoint_daily_check_id_day_pk": { + "columns": [ + "check_id", + "day" + ], + "name": "endpoint_daily_check_id_day_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_hourly": { + "name": "endpoint_hourly", + "columns": { + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hour": { + "name": "hour", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total": { + "name": "total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_sum": { + "name": "ms_sum", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_count": { + "name": "ms_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_max": { + "name": "ms_max", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "endpoint_hourly_check_id_endpoint_checks_id_fk": { + "name": "endpoint_hourly_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_hourly", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "endpoint_hourly_check_id_hour_pk": { + "columns": [ + "check_id", + "hour" + ], + "name": "endpoint_hourly_check_id_hour_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_results": { + "name": "endpoint_results", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ms": { + "name": "ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "endpoint_results_check_idx": { + "name": "endpoint_results_check_idx", + "columns": [ + "check_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "endpoint_results_check_id_endpoint_checks_id_fk": { + "name": "endpoint_results_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_results", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "event_webhooks": { + "name": "event_webhooks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "events": { + "name": "events", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_result": { + "name": "last_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "fragnet_state": { + "name": "fragnet_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "servers": { + "name": "servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "fragnet_state_integration_id_integrations_id_fk": { + "name": "fragnet_state_integration_id_integrations_id_fk", + "tableFrom": "fragnet_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_entities": { + "name": "ha_entities", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "friendly_name": { + "name": "friendly_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_class": { + "name": "device_class", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_changed": { + "name": "last_changed", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unavailable_since": { + "name": "unavailable_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "ha_entities_integration_id_integrations_id_fk": { + "name": "ha_entities_integration_id_integrations_id_fk", + "tableFrom": "ha_entities", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "ha_entities_integration_id_entity_id_pk": { + "columns": [ + "integration_id", + "entity_id" + ], + "name": "ha_entities_integration_id_entity_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_readings": { + "name": "ha_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "ha_readings_lookup_idx": { + "name": "ha_readings_lookup_idx", + "columns": [ + "integration_id", + "entity_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ha_readings_integration_id_integrations_id_fk": { + "name": "ha_readings_integration_id_integrations_id_fk", + "tableFrom": "ha_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_watched": { + "name": "ha_watched", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "above": { + "name": "above", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "below": { + "name": "below", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "ha_watched_unique": { + "name": "ha_watched_unique", + "columns": [ + "integration_id", + "entity_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "ha_watched_integration_id_integrations_id_fk": { + "name": "ha_watched_integration_id_integrations_id_fk", + "tableFrom": "ha_watched", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "heartbeat_pings": { + "name": "heartbeat_pings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "heartbeat_id": { + "name": "heartbeat_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "heartbeat_pings_idx": { + "name": "heartbeat_pings_idx", + "columns": [ + "heartbeat_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "heartbeat_pings_heartbeat_id_heartbeats_id_fk": { + "name": "heartbeat_pings_heartbeat_id_heartbeats_id_fk", + "tableFrom": "heartbeat_pings", + "tableTo": "heartbeats", + "columnsFrom": [ + "heartbeat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "heartbeats": { + "name": "heartbeats", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period_minutes": { + "name": "period_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "grace_minutes": { + "name": "grace_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_ping_at": { + "name": "last_ping_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_status": { + "name": "last_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_message": { + "name": "last_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_duration_ms": { + "name": "last_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_start_at": { + "name": "last_start_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ping_count": { + "name": "ping_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "heartbeats_token_unique": { + "name": "heartbeats_token_unique", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "hetzner_state": { + "name": "hetzner_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "servers": { + "name": "servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "volumes": { + "name": "volumes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_balancers": { + "name": "load_balancers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "floating_ips": { + "name": "floating_ips", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "certificates": { + "name": "certificates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "hetzner_state_integration_id_integrations_id_fk": { + "name": "hetzner_state_integration_id_integrations_id_fk", + "tableFrom": "hetzner_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "immich_state": { + "name": "immich_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "disk_size": { + "name": "disk_size", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disk_used": { + "name": "disk_used", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disk_percent": { + "name": "disk_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "photos": { + "name": "photos", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "videos": { + "name": "videos", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "usage_bytes": { + "name": "usage_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "queues": { + "name": "queues", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "immich_state_integration_id_integrations_id_fk": { + "name": "immich_state_integration_id_integrations_id_fk", + "tableFrom": "immich_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "incident_notes": { + "name": "incident_notes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "incident_id": { + "name": "incident_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "incident_notes_incident_idx": { + "name": "incident_notes_incident_idx", + "columns": [ + "incident_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "incident_notes_incident_id_alert_incidents_id_fk": { + "name": "incident_notes_incident_id_alert_incidents_id_fk", + "tableFrom": "incident_notes", + "tableTo": "alert_incidents", + "columnsFrom": [ + "incident_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "integration_credentials": { + "name": "integration_credentials", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "encrypted_secret": { + "name": "encrypted_secret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "integrations": { + "name": "integrations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "integrations_credential_id_integration_credentials_id_fk": { + "name": "integrations_credential_id_integration_credentials_id_fk", + "tableFrom": "integrations", + "tableTo": "integration_credentials", + "columnsFrom": [ + "credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ipam_entries": { + "name": "ipam_entries", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "vendor": { + "name": "vendor", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "ipam_entries_ip_address_unique": { + "name": "ipam_entries_ip_address_unique", + "columns": [ + "ip_address" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jellyfin_readings": { + "name": "jellyfin_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "streams": { + "name": "streams", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "transcodes": { + "name": "transcodes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "jellyfin_readings_idx": { + "name": "jellyfin_readings_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "jellyfin_readings_integration_id_integrations_id_fk": { + "name": "jellyfin_readings_integration_id_integrations_id_fk", + "tableFrom": "jellyfin_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jellyfin_state": { + "name": "jellyfin_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os": { + "name": "os", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pending_restart": { + "name": "pending_restart", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "streams": { + "name": "streams", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "tasks": { + "name": "tasks", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "movies": { + "name": "movies", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "series": { + "name": "series", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "episodes": { + "name": "episodes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "songs": { + "name": "songs", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failed_logins_24h": { + "name": "failed_logins_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "jellyfin_state_integration_id_integrations_id_fk": { + "name": "jellyfin_state_integration_id_integrations_id_fk", + "tableFrom": "jellyfin_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_aliases": { + "name": "maintenance_aliases", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "maintenance_aliases_unique_idx": { + "name": "maintenance_aliases_unique_idx", + "columns": [ + "address", + "target_type", + "target_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_schedules": { + "name": "maintenance_schedules", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "targets": { + "name": "targets", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "days": { + "name": "days", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_windows": { + "name": "maintenance_windows", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ends_at": { + "name": "ends_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "metrics_tokens": { + "name": "metrics_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "metrics_tokens_token_hash_unique": { + "name": "metrics_tokens_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "n8n_state": { + "name": "n8n_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "workflows": { + "name": "workflows", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "executions_known": { + "name": "executions_known", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "n8n_state_integration_id_integrations_id_fk": { + "name": "n8n_state_integration_id_integrations_id_fk", + "tableFrom": "n8n_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "netbox_state": { + "name": "netbox_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workers_running": { + "name": "workers_running", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "devices": { + "name": "devices", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "virtual_machines": { + "name": "virtual_machines", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prefixes": { + "name": "prefixes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ip_addresses": { + "name": "ip_addresses", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ips": { + "name": "ips", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "netbox_state_integration_id_integrations_id_fk": { + "name": "netbox_state_integration_id_integrations_id_fk", + "tableFrom": "netbox_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_devices": { + "name": "network_devices", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "site_name": { + "name": "site_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mac": { + "name": "mac", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "uptime_seconds": { + "name": "uptime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "firmware": { + "name": "firmware", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "firmware_updatable": { + "name": "firmware_updatable", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "uplink_external_id": { + "name": "uplink_external_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "offline_since": { + "name": "offline_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_online_at": { + "name": "last_online_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_devices_unique": { + "name": "network_devices_unique", + "columns": [ + "integration_id", + "external_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_devices_integration_id_integrations_id_fk": { + "name": "network_devices_integration_id_integrations_id_fk", + "tableFrom": "network_devices", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_segments": { + "name": "network_segments", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "site_name": { + "name": "site_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "vlan_id": { + "name": "vlan_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "subnet": { + "name": "subnet", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "security": { + "name": "security", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "network_name": { + "name": "network_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_segments_unique": { + "name": "network_segments_unique", + "columns": [ + "integration_id", + "kind", + "external_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_segments_integration_id_integrations_id_fk": { + "name": "network_segments_integration_id_integrations_id_fk", + "tableFrom": "network_segments", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_server_links": { + "name": "network_server_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "device_external_id": { + "name": "device_external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_mac": { + "name": "client_mac", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "wired": { + "name": "wired", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_server_links_unique": { + "name": "network_server_links_unique", + "columns": [ + "integration_id", + "server_id", + "client_mac" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_server_links_integration_id_integrations_id_fk": { + "name": "network_server_links_integration_id_integrations_id_fk", + "tableFrom": "network_server_links", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "network_server_links_server_id_servers_id_fk": { + "name": "network_server_links_server_id_servers_id_fk", + "tableFrom": "network_server_links", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "nextcloud_state": { + "name": "nextcloud_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "maintenance": { + "name": "maintenance", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "needs_upgrade": { + "name": "needs_upgrade", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "detail": { + "name": "detail", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "free_bytes": { + "name": "free_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "users": { + "name": "users", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "files": { + "name": "files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_24h": { + "name": "active_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "app_updates": { + "name": "app_updates", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "core_update": { + "name": "core_update", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cron_state": { + "name": "cron_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cron_text": { + "name": "cron_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "setup_issues": { + "name": "setup_issues", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "nextcloud_state_integration_id_integrations_id_fk": { + "name": "nextcloud_state_integration_id_integrations_id_fk", + "tableFrom": "nextcloud_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "note_photos": { + "name": "note_photos", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_id": { + "name": "device_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data": { + "name": "data", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "note_photos_server_idx": { + "name": "note_photos_server_idx", + "columns": [ + "server_id" + ], + "isUnique": false + }, + "note_photos_device_idx": { + "name": "note_photos_device_idx", + "columns": [ + "device_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "note_photos_server_id_servers_id_fk": { + "name": "note_photos_server_id_servers_id_fk", + "tableFrom": "note_photos", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "note_photos_device_id_network_devices_id_fk": { + "name": "note_photos_device_id_network_devices_id_fk", + "tableFrom": "note_photos", + "tableTo": "network_devices", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notes": { + "name": "notes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "notes_target_idx": { + "name": "notes_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notification_queue": { + "name": "notification_queue", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "paperless_state": { + "name": "paperless_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "storage_total": { + "name": "storage_total", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "storage_available": { + "name": "storage_available", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "components": { + "name": "components", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "documents": { + "name": "documents", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "inbox": { + "name": "inbox", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failed": { + "name": "failed", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "paperless_state_integration_id_integrations_id_fk": { + "name": "paperless_state_integration_id_integrations_id_fk", + "tableFrom": "paperless_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "patch_plan_runs": { + "name": "patch_plan_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "plan_id": { + "name": "plan_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plan_name": { + "name": "plan_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "started_by": { + "name": "started_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "items": { + "name": "items", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "patch_plan_runs_plan_idx": { + "name": "patch_plan_runs_plan_idx", + "columns": [ + "plan_id", + "started_at" + ], + "isUnique": false + }, + "patch_plan_runs_status_idx": { + "name": "patch_plan_runs_status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "patch_plan_runs_plan_id_patch_plans_id_fk": { + "name": "patch_plan_runs_plan_id_patch_plans_id_fk", + "tableFrom": "patch_plan_runs", + "tableTo": "patch_plans", + "columnsFrom": [ + "plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "patch_plans": { + "name": "patch_plans", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "days": { + "name": "days", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "server_ids": { + "name": "server_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "limit_from": { + "name": "limit_from", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'name'" + }, + "stop_on_failure": { + "name": "stop_on_failure", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "only_with_updates": { + "name": "only_with_updates", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "silence_dependents": { + "name": "silence_dependents", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "window_minutes": { + "name": "window_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 90 + }, + "last_run_date": { + "name": "last_run_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "port_forwards": { + "name": "port_forwards", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_port": { + "name": "external_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tcp'" + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "destination": { + "name": "destination", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "internal_port": { + "name": "internal_port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "port_forwards_server_id_servers_id_fk": { + "name": "port_forwards_server_id_servers_id_fk", + "tableFrom": "port_forwards", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "prometheus_state": { + "name": "prometheus_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "jobs": { + "name": "jobs", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "down": { + "name": "down", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alerts": { + "name": "alerts", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "prometheus_state_integration_id_integrations_id_fk": { + "name": "prometheus_state_integration_id_integrations_id_fk", + "tableFrom": "prometheus_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "push_subscriptions": { + "name": "push_subscriptions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_success_at": { + "name": "last_success_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "min_severity": { + "name": "min_severity", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "categories": { + "name": "categories", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "push_subscriptions_endpoint_unique": { + "name": "push_subscriptions_endpoint_unique", + "columns": [ + "endpoint" + ], + "isUnique": true + } + }, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "renewals": { + "name": "renewals", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_date": { + "name": "from_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_date": { + "name": "to_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "renewals_at_idx": { + "name": "renewals_at_idx", + "columns": [ + "at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "restore_tests": { + "name": "restore_tests", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "subject_key": { + "name": "subject_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tested_at": { + "name": "tested_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tested_by": { + "name": "tested_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "restore_tests_subject_idx": { + "name": "restore_tests_subject_idx", + "columns": [ + "subject_key", + "tested_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runbooks": { + "name": "runbooks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "runbooks_target_idx": { + "name": "runbooks_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scheduled_tasks": { + "name": "scheduled_tasks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schedule_type": { + "name": "schedule_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'agent'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "command": { + "name": "command", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "schedule_expression": { + "name": "schedule_expression", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "raw_metadata": { + "name": "raw_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_stale": { + "name": "is_stale", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "scheduled_tasks_server_id_servers_id_fk": { + "name": "scheduled_tasks_server_id_servers_id_fk", + "tableFrom": "scheduled_tasks", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "secrets": { + "name": "secrets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'generic'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expiry_date": { + "name": "expiry_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warn_days": { + "name": "warn_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 30 + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_host": { + "name": "check_host", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_port": { + "name": "check_port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_links": { + "name": "server_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "server_links_server_id_servers_id_fk": { + "name": "server_links_server_id_servers_id_fk", + "tableFrom": "server_links", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_metrics": { + "name": "server_metrics", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "recorded_at": { + "name": "recorded_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "server_metrics_lookup_idx": { + "name": "server_metrics_lookup_idx", + "columns": [ + "server_id", + "metric", + "recorded_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "server_metrics_server_id_servers_id_fk": { + "name": "server_metrics_server_id_servers_id_fk", + "tableFrom": "server_metrics", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_metrics_rollup": { + "name": "server_metrics_rollup", + "columns": { + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "grain": { + "name": "grain", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sum": { + "name": "sum", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "n": { + "name": "n", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "min": { + "name": "min", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "max": { + "name": "max", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "server_metrics_rollup_server_id_servers_id_fk": { + "name": "server_metrics_rollup_server_id_servers_id_fk", + "tableFrom": "server_metrics_rollup", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "server_metrics_rollup_server_id_metric_grain_at_pk": { + "columns": [ + "server_id", + "metric", + "grain", + "at" + ], + "name": "server_metrics_rollup_server_id_metric_grain_at_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_ports": { + "name": "server_ports", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tcp'" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "open": { + "name": "open", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "last_seen_open_at": { + "name": "last_seen_open_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "server_ports_unique": { + "name": "server_ports_unique", + "columns": [ + "server_id", + "port", + "protocol" + ], + "isUnique": true + } + }, + "foreignKeys": { + "server_ports_server_id_servers_id_fk": { + "name": "server_ports_server_id_servers_id_fk", + "tableFrom": "server_ports", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "servers": { + "name": "servers", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hostname": { + "name": "hostname", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_type": { + "name": "os_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'linux'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "api_token_hash": { + "name": "api_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "api_token_prefix": { + "name": "api_token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ip_addresses": { + "name": "ip_addresses", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_model": { + "name": "cpu_model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_cores": { + "name": "cpu_cores", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_load_percent": { + "name": "cpu_load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mem_total_bytes": { + "name": "mem_total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mem_used_bytes": { + "name": "mem_used_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disks": { + "name": "disks", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "listening_ports": { + "name": "listening_ports", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_port_scan": { + "name": "last_port_scan", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_integration_id": { + "name": "proxmox_integration_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_node": { + "name": "proxmox_node", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_guest_type": { + "name": "proxmox_guest_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_vmid": { + "name": "proxmox_vmid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hide_proxmox_link": { + "name": "hide_proxmox_link", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "parent_server_id": { + "name": "parent_server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "no_parent": { + "name": "no_parent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "pending_updates": { + "name": "pending_updates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_pending_since": { + "name": "updates_pending_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host_health": { + "name": "host_health", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_diagnostics": { + "name": "agent_diagnostics", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "port_baseline": { + "name": "port_baseline", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_id": { + "name": "os_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_name": { + "name": "os_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_version": { + "name": "os_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_manufacturer": { + "name": "hw_manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_model": { + "name": "hw_model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_serial": { + "name": "hw_serial", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "thresholds": { + "name": "thresholds", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_version": { + "name": "agent_version", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "servers_proxmox_integration_id_integrations_id_fk": { + "name": "servers_proxmox_integration_id_integrations_id_fk", + "tableFrom": "servers", + "tableTo": "integrations", + "columnsFrom": [ + "proxmox_integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "service_levels": { + "name": "service_levels", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_type": { + "name": "subject_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_id": { + "name": "subject_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target": { + "name": "target", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "alert": { + "name": "alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "share_links": { + "name": "share_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'summary'" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'wall'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "share_links_token_hash_unique": { + "name": "share_links_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "speedtest_results": { + "name": "speedtest_results", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result_id": { + "name": "result_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "download_bps": { + "name": "download_bps", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "upload_bps": { + "name": "upload_bps", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ping_ms": { + "name": "ping_ms", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "healthy": { + "name": "healthy", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "speedtest_results_at_idx": { + "name": "speedtest_results_at_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "speedtest_results_integration_id_integrations_id_fk": { + "name": "speedtest_results_integration_id_integrations_id_fk", + "tableFrom": "speedtest_results", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "speedtest_results_integration_id_result_id_pk": { + "columns": [ + "integration_id", + "result_id" + ], + "name": "speedtest_results_integration_id_result_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "status_items": { + "name": "status_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "link_id": { + "name": "link_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "monitor_id": { + "name": "monitor_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "status_items_link_idx": { + "name": "status_items_link_idx", + "columns": [ + "link_id", + "position" + ], + "isUnique": false + } + }, + "foreignKeys": { + "status_items_link_id_share_links_id_fk": { + "name": "status_items_link_id_share_links_id_fk", + "tableFrom": "status_items", + "tableTo": "share_links", + "columnsFrom": [ + "link_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "storage_samples": { + "name": "storage_samples", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "series_id": { + "name": "series_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "storage_samples_series_idx": { + "name": "storage_samples_series_idx", + "columns": [ + "series_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "storage_samples_series_id_storage_series_id_fk": { + "name": "storage_samples_series_id_storage_series_id_fk", + "tableFrom": "storage_samples", + "tableTo": "storage_series", + "columnsFrom": [ + "series_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "storage_series": { + "name": "storage_series", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "latest_percent": { + "name": "latest_percent", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "used_bytes": { + "name": "used_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "storage_series_key_idx": { + "name": "storage_series_key_idx", + "columns": [ + "integration_id", + "key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "storage_series_integration_id_integrations_id_fk": { + "name": "storage_series_integration_id_integrations_id_fk", + "tableFrom": "storage_series", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tag_definitions": { + "name": "tag_definitions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "tag_definitions_name_unique": { + "name": "tag_definitions_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "todos": { + "name": "todos", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_name": { + "name": "assignee_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "done_at": { + "name": "done_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "done_by": { + "name": "done_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "todos_assignee_user_id_users_id_fk": { + "name": "todos_assignee_user_id_users_id_fk", + "tableFrom": "todos", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "update_runs": { + "name": "update_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "host_limit": { + "name": "host_limit", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_status": { + "name": "task_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "window_id": { + "name": "window_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "window_created": { + "name": "window_created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_by": { + "name": "started_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_ended_at": { + "name": "task_ended_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host_reported_at": { + "name": "host_reported_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_before": { + "name": "updates_before", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_after": { + "name": "updates_after", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reboot_required": { + "name": "reboot_required", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "poll_errors": { + "name": "poll_errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "update_runs_server_idx": { + "name": "update_runs_server_idx", + "columns": [ + "server_id", + "started_at" + ], + "isUnique": false + }, + "update_runs_status_idx": { + "name": "update_runs_status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "update_runs_server_id_servers_id_fk": { + "name": "update_runs_server_id_servers_id_fk", + "tableFrom": "update_runs", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ups_readings": { + "name": "ups_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "charge": { + "name": "charge", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_seconds": { + "name": "runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_percent": { + "name": "load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_voltage": { + "name": "input_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "on_battery": { + "name": "on_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "ups_readings_lookup_idx": { + "name": "ups_readings_lookup_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ups_readings_integration_id_integrations_id_fk": { + "name": "ups_readings_integration_id_integrations_id_fk", + "tableFrom": "ups_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ups_state": { + "name": "ups_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_text": { + "name": "status_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "on_battery": { + "name": "on_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "low_battery": { + "name": "low_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "replace_battery": { + "name": "replace_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "overload": { + "name": "overload", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "charge": { + "name": "charge", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_seconds": { + "name": "runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_percent": { + "name": "load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_voltage": { + "name": "input_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_voltage": { + "name": "output_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "on_battery_since": { + "name": "on_battery_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "ups_state_integration_id_integrations_id_fk": { + "name": "ups_state_integration_id_integrations_id_fk", + "tableFrom": "ups_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "oidc_sub": { + "name": "oidc_sub", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'viewer'" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_login_at": { + "name": "last_login_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "favorites": { + "name": "favorites", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_looked_at": { + "name": "last_looked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "groups": { + "name": "groups", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dashboard_layout": { + "name": "dashboard_layout", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "picture_url": { + "name": "picture_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "users_oidc_sub_unique": { + "name": "users_oidc_sub_unique", + "columns": [ + "oidc_sub" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "webhook_deliveries": { + "name": "webhook_deliveries", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "webhook_id": { + "name": "webhook_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event": { + "name": "event", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "delivery_id": { + "name": "delivery_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "retry_of": { + "name": "retry_of", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "webhook_deliveries_webhook_idx": { + "name": "webhook_deliveries_webhook_idx", + "columns": [ + "webhook_id", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "webhook_deliveries_webhook_id_event_webhooks_id_fk": { + "name": "webhook_deliveries_webhook_id_event_webhooks_id_fk", + "tableFrom": "webhook_deliveries", + "tableTo": "event_webhooks", + "columnsFrom": [ + "webhook_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/drizzle/meta/0073_snapshot.json b/server/drizzle/meta/0073_snapshot.json new file mode 100644 index 0000000..7e141b3 --- /dev/null +++ b/server/drizzle/meta/0073_snapshot.json @@ -0,0 +1,8094 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "706b494b-29f9-42b0-be39-964fcb195712", + "prevId": "76deb0f5-470b-48ce-b0ff-e8bb864f893c", + "tables": { + "alert_acks": { + "name": "alert_acks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_name": { + "name": "assignee_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "acked_by": { + "name": "acked_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "acked_at": { + "name": "acked_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "until": { + "name": "until", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "alert_acks_key_idx": { + "name": "alert_acks_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "alert_acks_assignee_user_id_users_id_fk": { + "name": "alert_acks_assignee_user_id_users_id_fk", + "tableFrom": "alert_acks", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_incidents": { + "name": "alert_incidents", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "peak_severity": { + "name": "peak_severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_name": { + "name": "target_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "caused_by": { + "name": "caused_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "opened_at": { + "name": "opened_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "missing_since": { + "name": "missing_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "escalated_step": { + "name": "escalated_step", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "escalated_at": { + "name": "escalated_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_incidents_key_idx": { + "name": "alert_incidents_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": false + }, + "alert_incidents_opened_idx": { + "name": "alert_incidents_opened_idx", + "columns": [ + "opened_at" + ], + "isUnique": false + }, + "alert_incidents_target_idx": { + "name": "alert_incidents_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_rules": { + "name": "alert_rules", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mount": { + "name": "mount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "operator": { + "name": "operator", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'above'" + }, + "threshold": { + "name": "threshold", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "for_minutes": { + "name": "for_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'warning'" + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_snoozes": { + "name": "alert_snoozes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_id": { + "name": "alert_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "condition_key": { + "name": "condition_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "until": { + "name": "until", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snoozed_by": { + "name": "snoozed_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snoozed_at": { + "name": "snoozed_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'snooze'" + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_snoozes_alert_idx": { + "name": "alert_snoozes_alert_idx", + "columns": [ + "alert_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_tickets": { + "name": "alert_tickets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "seen_count": { + "name": "seen_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_number": { + "name": "ticket_number", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "grouped": { + "name": "grouped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ticketed_at": { + "name": "ticketed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cleared_at": { + "name": "cleared_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_closed_at": { + "name": "ticket_closed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_closed_by": { + "name": "ticket_closed_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_tickets_key_idx": { + "name": "alert_tickets_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": false + } + }, + "foreignKeys": { + "alert_tickets_integration_id_integrations_id_fk": { + "name": "alert_tickets_integration_id_integrations_id_fk", + "tableFrom": "alert_tickets", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "api_tokens": { + "name": "api_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "api_tokens_token_hash_unique": { + "name": "api_tokens_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": { + "api_tokens_user_id_users_id_fk": { + "name": "api_tokens_user_id_users_id_fk", + "tableFrom": "api_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "arr_state": { + "name": "arr_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "health": { + "name": "health", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "queue": { + "name": "queue", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disks": { + "name": "disks", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "missing": { + "name": "missing", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "indexers": { + "name": "indexers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "arr_state_integration_id_integrations_id_fk": { + "name": "arr_state_integration_id_integrations_id_fk", + "tableFrom": "arr_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "assets": { + "name": "assets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "serial": { + "name": "serial", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purchase_date": { + "name": "purchase_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purchase_price": { + "name": "purchase_price", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warranty_until": { + "name": "warranty_until", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "end_of_support": { + "name": "end_of_support", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "replacement_cost": { + "name": "replacement_cost", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "rack_unit": { + "name": "rack_unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "power_watts": { + "name": "power_watts", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "audit_log": { + "name": "audit_log", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_label": { + "name": "actor_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "audit_log_actor_user_id_users_id_fk": { + "name": "audit_log_actor_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "authentik_state": { + "name": "authentik_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "outdated": { + "name": "outdated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "workers": { + "name": "workers", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "outposts": { + "name": "outposts", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "certificates": { + "name": "certificates", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "tokens": { + "name": "tokens", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "failed_logins_24h": { + "name": "failed_logins_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config_errors_24h": { + "name": "config_errors_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_config_error": { + "name": "last_config_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "authentik_state_integration_id_integrations_id_fk": { + "name": "authentik_state_integration_id_integrations_id_fk", + "tableFrom": "authentik_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "consistency_ignores": { + "name": "consistency_ignores", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "consistency_ignores_key_unique": { + "name": "consistency_ignores_key_unique", + "columns": [ + "key" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "cost_items": { + "name": "cost_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Other'" + }, + "renews_on": { + "name": "renews_on", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dependencies": { + "name": "dependencies", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "from_type": { + "name": "from_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_id": { + "name": "from_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_type": { + "name": "to_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_id": { + "name": "to_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "dependencies_edge_idx": { + "name": "dependencies_edge_idx", + "columns": [ + "from_type", + "from_id", + "to_type", + "to_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "diag_log": { + "name": "diag_log", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "operation": { + "name": "operation", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "latency_ms": { + "name": "latency_ms", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_providers": { + "name": "dns_providers", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_type": { + "name": "provider_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "dns_providers_credential_id_integration_credentials_id_fk": { + "name": "dns_providers_credential_id_integration_credentials_id_fk", + "tableFrom": "dns_providers", + "tableTo": "integration_credentials", + "columnsFrom": [ + "credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_records_cache": { + "name": "dns_records_cache", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_id": { + "name": "provider_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "record_id": { + "name": "record_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ttl": { + "name": "ttl", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxied": { + "name": "proxied", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "dns_records_cache_provider_id_dns_providers_id_fk": { + "name": "dns_records_cache_provider_id_dns_providers_id_fk", + "tableFrom": "dns_records_cache", + "tableTo": "dns_providers", + "columnsFrom": [ + "provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_zones_cache": { + "name": "dns_zones_cache", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_id": { + "name": "provider_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_name": { + "name": "zone_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "synced_at": { + "name": "synced_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "dns_zones_cache_provider_zone_idx": { + "name": "dns_zones_cache_provider_zone_idx", + "columns": [ + "provider_id", + "zone_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "dns_zones_cache_provider_id_dns_providers_id_fk": { + "name": "dns_zones_cache_provider_id_dns_providers_id_fk", + "tableFrom": "dns_zones_cache", + "tableTo": "dns_providers", + "columnsFrom": [ + "provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dockhand_vulnerabilities": { + "name": "dockhand_vulnerabilities", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_id": { + "name": "environment_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_name": { + "name": "environment_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "critical": { + "name": "critical", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "high": { + "name": "high", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "medium": { + "name": "medium", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "low": { + "name": "low", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images_scanned": { + "name": "images_scanned", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_images": { + "name": "total_images", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "findings": { + "name": "findings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "dockhand_vulnerabilities_integration_id_integrations_id_fk": { + "name": "dockhand_vulnerabilities_integration_id_integrations_id_fk", + "tableFrom": "dockhand_vulnerabilities", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "dockhand_vulnerabilities_integration_id_environment_id_pk": { + "columns": [ + "integration_id", + "environment_id" + ], + "name": "dockhand_vulnerabilities_integration_id_environment_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "domains": { + "name": "domains", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'manual'" + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "registrar": { + "name": "registrar", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lookup_source": { + "name": "lookup_source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_ok_at": { + "name": "last_checked_ok_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "domains_name_unique": { + "name": "domains_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_backups": { + "name": "duplicati_backups", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "source_id": { + "name": "source_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_report_at": { + "name": "last_report_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_result": { + "name": "last_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_begin": { + "name": "last_begin", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_end": { + "name": "last_end", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_seconds": { + "name": "duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "examined_files": { + "name": "examined_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_files": { + "name": "added_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "modified_files": { + "name": "modified_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deleted_files": { + "name": "deleted_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warnings": { + "name": "warnings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "errors": { + "name": "errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "expected_hours": { + "name": "expected_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 48 + }, + "alert": { + "name": "alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "duplicati_backups_name_idx": { + "name": "duplicati_backups_name_idx", + "columns": [ + "source_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "duplicati_backups_source_id_duplicati_sources_id_fk": { + "name": "duplicati_backups_source_id_duplicati_sources_id_fk", + "tableFrom": "duplicati_backups", + "tableTo": "duplicati_sources", + "columnsFrom": [ + "source_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_runs": { + "name": "duplicati_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "backup_id": { + "name": "backup_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_seconds": { + "name": "duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "files_changed": { + "name": "files_changed", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warnings": { + "name": "warnings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "errors": { + "name": "errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "duplicati_runs_idx": { + "name": "duplicati_runs_idx", + "columns": [ + "backup_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "duplicati_runs_backup_id_duplicati_backups_id_fk": { + "name": "duplicati_runs_backup_id_duplicati_backups_id_fk", + "tableFrom": "duplicati_runs", + "tableTo": "duplicati_backups", + "columnsFrom": [ + "backup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_sources": { + "name": "duplicati_sources", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_report_at": { + "name": "last_report_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "duplicati_sources_token_hash_unique": { + "name": "duplicati_sources_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_checks": { + "name": "endpoint_checks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expect_status": { + "name": "expect_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "insecure": { + "name": "insecure", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "value_path": { + "name": "value_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_op": { + "name": "value_op", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_expected": { + "name": "value_expected", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_unit": { + "name": "value_unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "header_name": { + "name": "header_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "header_value": { + "name": "header_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_value": { + "name": "last_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "interval_minutes": { + "name": "interval_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 5 + }, + "timeout_seconds": { + "name": "timeout_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "failures_before_alert": { + "name": "failures_before_alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 2 + }, + "warn_days": { + "name": "warn_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 14 + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_ok": { + "name": "last_ok", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_message": { + "name": "last_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_response_ms": { + "name": "last_response_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cert_expires_at": { + "name": "cert_expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_change_at": { + "name": "last_change_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_daily": { + "name": "endpoint_daily", + "columns": { + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "day": { + "name": "day", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total": { + "name": "total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_sum": { + "name": "ms_sum", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_count": { + "name": "ms_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "endpoint_daily_check_id_endpoint_checks_id_fk": { + "name": "endpoint_daily_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_daily", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "endpoint_daily_check_id_day_pk": { + "columns": [ + "check_id", + "day" + ], + "name": "endpoint_daily_check_id_day_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_hourly": { + "name": "endpoint_hourly", + "columns": { + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hour": { + "name": "hour", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total": { + "name": "total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_sum": { + "name": "ms_sum", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_count": { + "name": "ms_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_max": { + "name": "ms_max", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "endpoint_hourly_check_id_endpoint_checks_id_fk": { + "name": "endpoint_hourly_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_hourly", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "endpoint_hourly_check_id_hour_pk": { + "columns": [ + "check_id", + "hour" + ], + "name": "endpoint_hourly_check_id_hour_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_results": { + "name": "endpoint_results", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ms": { + "name": "ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "endpoint_results_check_idx": { + "name": "endpoint_results_check_idx", + "columns": [ + "check_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "endpoint_results_check_id_endpoint_checks_id_fk": { + "name": "endpoint_results_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_results", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "event_webhooks": { + "name": "event_webhooks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "events": { + "name": "events", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_result": { + "name": "last_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "fragnet_state": { + "name": "fragnet_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "servers": { + "name": "servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "fragnet_state_integration_id_integrations_id_fk": { + "name": "fragnet_state_integration_id_integrations_id_fk", + "tableFrom": "fragnet_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_entities": { + "name": "ha_entities", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "friendly_name": { + "name": "friendly_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_class": { + "name": "device_class", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_changed": { + "name": "last_changed", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unavailable_since": { + "name": "unavailable_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "ha_entities_integration_id_integrations_id_fk": { + "name": "ha_entities_integration_id_integrations_id_fk", + "tableFrom": "ha_entities", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "ha_entities_integration_id_entity_id_pk": { + "columns": [ + "integration_id", + "entity_id" + ], + "name": "ha_entities_integration_id_entity_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_readings": { + "name": "ha_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "ha_readings_lookup_idx": { + "name": "ha_readings_lookup_idx", + "columns": [ + "integration_id", + "entity_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ha_readings_integration_id_integrations_id_fk": { + "name": "ha_readings_integration_id_integrations_id_fk", + "tableFrom": "ha_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_watched": { + "name": "ha_watched", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "above": { + "name": "above", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "below": { + "name": "below", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "ha_watched_unique": { + "name": "ha_watched_unique", + "columns": [ + "integration_id", + "entity_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "ha_watched_integration_id_integrations_id_fk": { + "name": "ha_watched_integration_id_integrations_id_fk", + "tableFrom": "ha_watched", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "heartbeat_pings": { + "name": "heartbeat_pings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "heartbeat_id": { + "name": "heartbeat_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "heartbeat_pings_idx": { + "name": "heartbeat_pings_idx", + "columns": [ + "heartbeat_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "heartbeat_pings_heartbeat_id_heartbeats_id_fk": { + "name": "heartbeat_pings_heartbeat_id_heartbeats_id_fk", + "tableFrom": "heartbeat_pings", + "tableTo": "heartbeats", + "columnsFrom": [ + "heartbeat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "heartbeats": { + "name": "heartbeats", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period_minutes": { + "name": "period_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "grace_minutes": { + "name": "grace_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_ping_at": { + "name": "last_ping_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_status": { + "name": "last_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_message": { + "name": "last_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_duration_ms": { + "name": "last_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_start_at": { + "name": "last_start_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ping_count": { + "name": "ping_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "heartbeats_token_unique": { + "name": "heartbeats_token_unique", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "hetzner_state": { + "name": "hetzner_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "servers": { + "name": "servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "volumes": { + "name": "volumes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_balancers": { + "name": "load_balancers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "floating_ips": { + "name": "floating_ips", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "certificates": { + "name": "certificates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "hetzner_state_integration_id_integrations_id_fk": { + "name": "hetzner_state_integration_id_integrations_id_fk", + "tableFrom": "hetzner_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "immich_state": { + "name": "immich_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "disk_size": { + "name": "disk_size", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disk_used": { + "name": "disk_used", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disk_percent": { + "name": "disk_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "photos": { + "name": "photos", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "videos": { + "name": "videos", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "usage_bytes": { + "name": "usage_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "queues": { + "name": "queues", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "immich_state_integration_id_integrations_id_fk": { + "name": "immich_state_integration_id_integrations_id_fk", + "tableFrom": "immich_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "incident_notes": { + "name": "incident_notes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "incident_id": { + "name": "incident_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "incident_notes_incident_idx": { + "name": "incident_notes_incident_idx", + "columns": [ + "incident_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "incident_notes_incident_id_alert_incidents_id_fk": { + "name": "incident_notes_incident_id_alert_incidents_id_fk", + "tableFrom": "incident_notes", + "tableTo": "alert_incidents", + "columnsFrom": [ + "incident_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "integration_credentials": { + "name": "integration_credentials", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "encrypted_secret": { + "name": "encrypted_secret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "integrations": { + "name": "integrations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "integrations_credential_id_integration_credentials_id_fk": { + "name": "integrations_credential_id_integration_credentials_id_fk", + "tableFrom": "integrations", + "tableTo": "integration_credentials", + "columnsFrom": [ + "credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ipam_entries": { + "name": "ipam_entries", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "vendor": { + "name": "vendor", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "ipam_entries_ip_address_unique": { + "name": "ipam_entries_ip_address_unique", + "columns": [ + "ip_address" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jellyfin_readings": { + "name": "jellyfin_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "streams": { + "name": "streams", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "transcodes": { + "name": "transcodes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "jellyfin_readings_idx": { + "name": "jellyfin_readings_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "jellyfin_readings_integration_id_integrations_id_fk": { + "name": "jellyfin_readings_integration_id_integrations_id_fk", + "tableFrom": "jellyfin_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jellyfin_state": { + "name": "jellyfin_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os": { + "name": "os", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pending_restart": { + "name": "pending_restart", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "streams": { + "name": "streams", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "tasks": { + "name": "tasks", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "movies": { + "name": "movies", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "series": { + "name": "series", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "episodes": { + "name": "episodes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "songs": { + "name": "songs", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failed_logins_24h": { + "name": "failed_logins_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "jellyfin_state_integration_id_integrations_id_fk": { + "name": "jellyfin_state_integration_id_integrations_id_fk", + "tableFrom": "jellyfin_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_aliases": { + "name": "maintenance_aliases", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "maintenance_aliases_unique_idx": { + "name": "maintenance_aliases_unique_idx", + "columns": [ + "address", + "target_type", + "target_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_schedules": { + "name": "maintenance_schedules", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "targets": { + "name": "targets", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "days": { + "name": "days", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_windows": { + "name": "maintenance_windows", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ends_at": { + "name": "ends_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "metrics_tokens": { + "name": "metrics_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "metrics_tokens_token_hash_unique": { + "name": "metrics_tokens_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "n8n_state": { + "name": "n8n_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "workflows": { + "name": "workflows", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "executions_known": { + "name": "executions_known", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "n8n_state_integration_id_integrations_id_fk": { + "name": "n8n_state_integration_id_integrations_id_fk", + "tableFrom": "n8n_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "netbox_state": { + "name": "netbox_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workers_running": { + "name": "workers_running", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "devices": { + "name": "devices", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "virtual_machines": { + "name": "virtual_machines", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prefixes": { + "name": "prefixes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ip_addresses": { + "name": "ip_addresses", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ips": { + "name": "ips", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "netbox_state_integration_id_integrations_id_fk": { + "name": "netbox_state_integration_id_integrations_id_fk", + "tableFrom": "netbox_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_devices": { + "name": "network_devices", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "site_name": { + "name": "site_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mac": { + "name": "mac", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "uptime_seconds": { + "name": "uptime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "firmware": { + "name": "firmware", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "firmware_updatable": { + "name": "firmware_updatable", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "uplink_external_id": { + "name": "uplink_external_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "offline_since": { + "name": "offline_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_online_at": { + "name": "last_online_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_devices_unique": { + "name": "network_devices_unique", + "columns": [ + "integration_id", + "external_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_devices_integration_id_integrations_id_fk": { + "name": "network_devices_integration_id_integrations_id_fk", + "tableFrom": "network_devices", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_segments": { + "name": "network_segments", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "site_name": { + "name": "site_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "vlan_id": { + "name": "vlan_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "subnet": { + "name": "subnet", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "security": { + "name": "security", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "network_name": { + "name": "network_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_segments_unique": { + "name": "network_segments_unique", + "columns": [ + "integration_id", + "kind", + "external_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_segments_integration_id_integrations_id_fk": { + "name": "network_segments_integration_id_integrations_id_fk", + "tableFrom": "network_segments", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_server_links": { + "name": "network_server_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "device_external_id": { + "name": "device_external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_mac": { + "name": "client_mac", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "wired": { + "name": "wired", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_server_links_unique": { + "name": "network_server_links_unique", + "columns": [ + "integration_id", + "server_id", + "client_mac" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_server_links_integration_id_integrations_id_fk": { + "name": "network_server_links_integration_id_integrations_id_fk", + "tableFrom": "network_server_links", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "network_server_links_server_id_servers_id_fk": { + "name": "network_server_links_server_id_servers_id_fk", + "tableFrom": "network_server_links", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "nextcloud_state": { + "name": "nextcloud_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "maintenance": { + "name": "maintenance", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "needs_upgrade": { + "name": "needs_upgrade", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "detail": { + "name": "detail", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "free_bytes": { + "name": "free_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "users": { + "name": "users", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "files": { + "name": "files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_24h": { + "name": "active_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "app_updates": { + "name": "app_updates", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "core_update": { + "name": "core_update", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cron_state": { + "name": "cron_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cron_text": { + "name": "cron_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "setup_issues": { + "name": "setup_issues", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "nextcloud_state_integration_id_integrations_id_fk": { + "name": "nextcloud_state_integration_id_integrations_id_fk", + "tableFrom": "nextcloud_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "note_photos": { + "name": "note_photos", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_id": { + "name": "device_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data": { + "name": "data", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "note_photos_server_idx": { + "name": "note_photos_server_idx", + "columns": [ + "server_id" + ], + "isUnique": false + }, + "note_photos_device_idx": { + "name": "note_photos_device_idx", + "columns": [ + "device_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "note_photos_server_id_servers_id_fk": { + "name": "note_photos_server_id_servers_id_fk", + "tableFrom": "note_photos", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "note_photos_device_id_network_devices_id_fk": { + "name": "note_photos_device_id_network_devices_id_fk", + "tableFrom": "note_photos", + "tableTo": "network_devices", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notes": { + "name": "notes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "notes_target_idx": { + "name": "notes_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notification_queue": { + "name": "notification_queue", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "paperless_state": { + "name": "paperless_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "storage_total": { + "name": "storage_total", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "storage_available": { + "name": "storage_available", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "components": { + "name": "components", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "documents": { + "name": "documents", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "inbox": { + "name": "inbox", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failed": { + "name": "failed", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "paperless_state_integration_id_integrations_id_fk": { + "name": "paperless_state_integration_id_integrations_id_fk", + "tableFrom": "paperless_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "patch_plan_runs": { + "name": "patch_plan_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "plan_id": { + "name": "plan_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plan_name": { + "name": "plan_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "started_by": { + "name": "started_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "items": { + "name": "items", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "patch_plan_runs_plan_idx": { + "name": "patch_plan_runs_plan_idx", + "columns": [ + "plan_id", + "started_at" + ], + "isUnique": false + }, + "patch_plan_runs_status_idx": { + "name": "patch_plan_runs_status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "patch_plan_runs_plan_id_patch_plans_id_fk": { + "name": "patch_plan_runs_plan_id_patch_plans_id_fk", + "tableFrom": "patch_plan_runs", + "tableTo": "patch_plans", + "columnsFrom": [ + "plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "patch_plans": { + "name": "patch_plans", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "days": { + "name": "days", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "server_ids": { + "name": "server_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "limit_from": { + "name": "limit_from", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'name'" + }, + "stop_on_failure": { + "name": "stop_on_failure", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "only_with_updates": { + "name": "only_with_updates", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "silence_dependents": { + "name": "silence_dependents", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "window_minutes": { + "name": "window_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 90 + }, + "last_run_date": { + "name": "last_run_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "port_forwards": { + "name": "port_forwards", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_port": { + "name": "external_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tcp'" + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "destination": { + "name": "destination", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "internal_port": { + "name": "internal_port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "port_forwards_server_id_servers_id_fk": { + "name": "port_forwards_server_id_servers_id_fk", + "tableFrom": "port_forwards", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "prometheus_state": { + "name": "prometheus_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "jobs": { + "name": "jobs", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "down": { + "name": "down", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alerts": { + "name": "alerts", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "prometheus_state_integration_id_integrations_id_fk": { + "name": "prometheus_state_integration_id_integrations_id_fk", + "tableFrom": "prometheus_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "push_subscriptions": { + "name": "push_subscriptions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_success_at": { + "name": "last_success_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "min_severity": { + "name": "min_severity", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "categories": { + "name": "categories", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "push_subscriptions_endpoint_unique": { + "name": "push_subscriptions_endpoint_unique", + "columns": [ + "endpoint" + ], + "isUnique": true + } + }, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "renewals": { + "name": "renewals", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_date": { + "name": "from_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_date": { + "name": "to_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "renewals_at_idx": { + "name": "renewals_at_idx", + "columns": [ + "at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "restore_tests": { + "name": "restore_tests", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "subject_key": { + "name": "subject_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tested_at": { + "name": "tested_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tested_by": { + "name": "tested_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "restore_tests_subject_idx": { + "name": "restore_tests_subject_idx", + "columns": [ + "subject_key", + "tested_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runbooks": { + "name": "runbooks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "runbooks_target_idx": { + "name": "runbooks_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scheduled_tasks": { + "name": "scheduled_tasks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schedule_type": { + "name": "schedule_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'agent'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "command": { + "name": "command", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "schedule_expression": { + "name": "schedule_expression", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "raw_metadata": { + "name": "raw_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_stale": { + "name": "is_stale", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "scheduled_tasks_server_id_servers_id_fk": { + "name": "scheduled_tasks_server_id_servers_id_fk", + "tableFrom": "scheduled_tasks", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "secrets": { + "name": "secrets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'generic'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expiry_date": { + "name": "expiry_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warn_days": { + "name": "warn_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 30 + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_host": { + "name": "check_host", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_port": { + "name": "check_port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_links": { + "name": "server_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "server_links_server_id_servers_id_fk": { + "name": "server_links_server_id_servers_id_fk", + "tableFrom": "server_links", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_metrics": { + "name": "server_metrics", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "recorded_at": { + "name": "recorded_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "server_metrics_lookup_idx": { + "name": "server_metrics_lookup_idx", + "columns": [ + "server_id", + "metric", + "recorded_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "server_metrics_server_id_servers_id_fk": { + "name": "server_metrics_server_id_servers_id_fk", + "tableFrom": "server_metrics", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_metrics_rollup": { + "name": "server_metrics_rollup", + "columns": { + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "grain": { + "name": "grain", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sum": { + "name": "sum", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "n": { + "name": "n", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "min": { + "name": "min", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "max": { + "name": "max", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "server_metrics_rollup_server_id_servers_id_fk": { + "name": "server_metrics_rollup_server_id_servers_id_fk", + "tableFrom": "server_metrics_rollup", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "server_metrics_rollup_server_id_metric_grain_at_pk": { + "columns": [ + "server_id", + "metric", + "grain", + "at" + ], + "name": "server_metrics_rollup_server_id_metric_grain_at_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_ports": { + "name": "server_ports", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tcp'" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "open": { + "name": "open", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "last_seen_open_at": { + "name": "last_seen_open_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "server_ports_unique": { + "name": "server_ports_unique", + "columns": [ + "server_id", + "port", + "protocol" + ], + "isUnique": true + } + }, + "foreignKeys": { + "server_ports_server_id_servers_id_fk": { + "name": "server_ports_server_id_servers_id_fk", + "tableFrom": "server_ports", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "servers": { + "name": "servers", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hostname": { + "name": "hostname", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_type": { + "name": "os_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'linux'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "api_token_hash": { + "name": "api_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "api_token_prefix": { + "name": "api_token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ip_addresses": { + "name": "ip_addresses", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_model": { + "name": "cpu_model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_cores": { + "name": "cpu_cores", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_load_percent": { + "name": "cpu_load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mem_total_bytes": { + "name": "mem_total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mem_used_bytes": { + "name": "mem_used_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disks": { + "name": "disks", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "listening_ports": { + "name": "listening_ports", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_port_scan": { + "name": "last_port_scan", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_integration_id": { + "name": "proxmox_integration_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_node": { + "name": "proxmox_node", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_guest_type": { + "name": "proxmox_guest_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_vmid": { + "name": "proxmox_vmid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hide_proxmox_link": { + "name": "hide_proxmox_link", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "parent_server_id": { + "name": "parent_server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "no_parent": { + "name": "no_parent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "pending_updates": { + "name": "pending_updates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_pending_since": { + "name": "updates_pending_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host_health": { + "name": "host_health", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_diagnostics": { + "name": "agent_diagnostics", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "port_baseline": { + "name": "port_baseline", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_id": { + "name": "os_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_name": { + "name": "os_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_version": { + "name": "os_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_manufacturer": { + "name": "hw_manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_model": { + "name": "hw_model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_serial": { + "name": "hw_serial", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "thresholds": { + "name": "thresholds", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_version": { + "name": "agent_version", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "servers_proxmox_integration_id_integrations_id_fk": { + "name": "servers_proxmox_integration_id_integrations_id_fk", + "tableFrom": "servers", + "tableTo": "integrations", + "columnsFrom": [ + "proxmox_integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "service_levels": { + "name": "service_levels", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_type": { + "name": "subject_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_id": { + "name": "subject_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target": { + "name": "target", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "alert": { + "name": "alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "share_links": { + "name": "share_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'summary'" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'wall'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "share_links_token_hash_unique": { + "name": "share_links_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "speedtest_results": { + "name": "speedtest_results", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result_id": { + "name": "result_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "download_bps": { + "name": "download_bps", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "upload_bps": { + "name": "upload_bps", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ping_ms": { + "name": "ping_ms", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "healthy": { + "name": "healthy", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "speedtest_results_at_idx": { + "name": "speedtest_results_at_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "speedtest_results_integration_id_integrations_id_fk": { + "name": "speedtest_results_integration_id_integrations_id_fk", + "tableFrom": "speedtest_results", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "speedtest_results_integration_id_result_id_pk": { + "columns": [ + "integration_id", + "result_id" + ], + "name": "speedtest_results_integration_id_result_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "status_items": { + "name": "status_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "link_id": { + "name": "link_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "monitor_id": { + "name": "monitor_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "status_items_link_idx": { + "name": "status_items_link_idx", + "columns": [ + "link_id", + "position" + ], + "isUnique": false + } + }, + "foreignKeys": { + "status_items_link_id_share_links_id_fk": { + "name": "status_items_link_id_share_links_id_fk", + "tableFrom": "status_items", + "tableTo": "share_links", + "columnsFrom": [ + "link_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "storage_samples": { + "name": "storage_samples", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "series_id": { + "name": "series_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "storage_samples_series_idx": { + "name": "storage_samples_series_idx", + "columns": [ + "series_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "storage_samples_series_id_storage_series_id_fk": { + "name": "storage_samples_series_id_storage_series_id_fk", + "tableFrom": "storage_samples", + "tableTo": "storage_series", + "columnsFrom": [ + "series_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "storage_series": { + "name": "storage_series", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "latest_percent": { + "name": "latest_percent", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "used_bytes": { + "name": "used_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "storage_series_key_idx": { + "name": "storage_series_key_idx", + "columns": [ + "integration_id", + "key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "storage_series_integration_id_integrations_id_fk": { + "name": "storage_series_integration_id_integrations_id_fk", + "tableFrom": "storage_series", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tag_definitions": { + "name": "tag_definitions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "tag_definitions_name_unique": { + "name": "tag_definitions_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "todos": { + "name": "todos", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_name": { + "name": "assignee_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "done_at": { + "name": "done_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "done_by": { + "name": "done_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "todos_assignee_user_id_users_id_fk": { + "name": "todos_assignee_user_id_users_id_fk", + "tableFrom": "todos", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "update_runs": { + "name": "update_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "host_limit": { + "name": "host_limit", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_status": { + "name": "task_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "window_id": { + "name": "window_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "window_created": { + "name": "window_created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_by": { + "name": "started_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_ended_at": { + "name": "task_ended_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host_reported_at": { + "name": "host_reported_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_before": { + "name": "updates_before", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_after": { + "name": "updates_after", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reboot_required": { + "name": "reboot_required", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "poll_errors": { + "name": "poll_errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "update_runs_server_idx": { + "name": "update_runs_server_idx", + "columns": [ + "server_id", + "started_at" + ], + "isUnique": false + }, + "update_runs_status_idx": { + "name": "update_runs_status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "update_runs_server_id_servers_id_fk": { + "name": "update_runs_server_id_servers_id_fk", + "tableFrom": "update_runs", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ups_readings": { + "name": "ups_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "charge": { + "name": "charge", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_seconds": { + "name": "runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_percent": { + "name": "load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_voltage": { + "name": "input_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "on_battery": { + "name": "on_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "ups_readings_lookup_idx": { + "name": "ups_readings_lookup_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ups_readings_integration_id_integrations_id_fk": { + "name": "ups_readings_integration_id_integrations_id_fk", + "tableFrom": "ups_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ups_state": { + "name": "ups_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_text": { + "name": "status_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "on_battery": { + "name": "on_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "low_battery": { + "name": "low_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "replace_battery": { + "name": "replace_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "overload": { + "name": "overload", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "charge": { + "name": "charge", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_seconds": { + "name": "runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_percent": { + "name": "load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_voltage": { + "name": "input_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_voltage": { + "name": "output_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "on_battery_since": { + "name": "on_battery_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "ups_state_integration_id_integrations_id_fk": { + "name": "ups_state_integration_id_integrations_id_fk", + "tableFrom": "ups_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "oidc_sub": { + "name": "oidc_sub", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'viewer'" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_login_at": { + "name": "last_login_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "favorites": { + "name": "favorites", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_looked_at": { + "name": "last_looked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "groups": { + "name": "groups", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dashboard_layout": { + "name": "dashboard_layout", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "picture_url": { + "name": "picture_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "users_oidc_sub_unique": { + "name": "users_oidc_sub_unique", + "columns": [ + "oidc_sub" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "webhook_deliveries": { + "name": "webhook_deliveries", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "webhook_id": { + "name": "webhook_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event": { + "name": "event", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "delivery_id": { + "name": "delivery_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "retry_of": { + "name": "retry_of", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "webhook_deliveries_webhook_idx": { + "name": "webhook_deliveries_webhook_idx", + "columns": [ + "webhook_id", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "webhook_deliveries_webhook_id_event_webhooks_id_fk": { + "name": "webhook_deliveries_webhook_id_event_webhooks_id_fk", + "tableFrom": "webhook_deliveries", + "tableTo": "event_webhooks", + "columnsFrom": [ + "webhook_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/drizzle/meta/_journal.json b/server/drizzle/meta/_journal.json index dbe92b6..bde0453 100644 --- a/server/drizzle/meta/_journal.json +++ b/server/drizzle/meta/_journal.json @@ -505,6 +505,20 @@ "when": 1793122879270, "tag": "0071_cuddly_strong_guy", "breakpoints": true + }, + { + "idx": 72, + "version": "6", + "when": 1793126445007, + "tag": "0072_fair_shiver_man", + "breakpoints": true + }, + { + "idx": 73, + "version": "6", + "when": 1793126767536, + "tag": "0073_chilly_silver_surfer", + "breakpoints": true } ] } \ No newline at end of file diff --git a/server/src/app.ts b/server/src/app.ts index 48a886e..28000c5 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -69,6 +69,7 @@ import { netboxRouter } from "./routes/netbox.js"; import { hetznerRouter } from "./routes/hetzner.js"; import { speedtestRouter } from "./routes/speedtest.js"; import { fragnetRouter } from "./routes/fragnet.js"; +import { arrRouter } from "./routes/arr.js"; import { costsRouter } from "./routes/costs.js"; import { nextcloudRouter } from "./routes/nextcloud.js"; import { serviceLevelsRouter } from "./routes/serviceLevels.js"; @@ -216,6 +217,7 @@ export function createApp() { app.use("/api/hetzner", hetznerRouter); app.use("/api/speedtest", speedtestRouter); app.use("/api/fragnet", fragnetRouter); + app.use("/api/arr", arrRouter); app.use("/api/costs", costsRouter); app.use("/api/nextcloud", nextcloudRouter); app.use("/api/service-levels", serviceLevelsRouter); diff --git a/server/src/db/schema.ts b/server/src/db/schema.ts index 0ce243f..0543026 100644 --- a/server/src/db/schema.ts +++ b/server/src/db/schema.ts @@ -564,6 +564,9 @@ export const integrationTypes = [ "hetzner", "speedtest", "fragnet", + "sonarr", + "radarr", + "prowlarr", ] as const; export type IntegrationType = (typeof integrationTypes)[number]; @@ -1270,6 +1273,9 @@ export const hetznerState = sqliteTable("hetzner_state", { servers: text("servers").notNull().default("[]"), // JSON: each server as read, plus when it was last seen running, since when it has had this status and since when rescue mode has been on volumes: text("volumes"), // JSON; null: could not be asked images: text("images"), // JSON: snapshots and backups; null: could not be asked + loadBalancers: text("load_balancers"), // JSON: each load balancer with the health of its targets; null: could not be asked + floatingIps: text("floating_ips"), // JSON; null: could not be asked + certificates: text("certificates"), // JSON: each certificate with when it ends; null: could not be asked cost: text("cost"), // JSON: the monthly estimate (currency, servers, backups, volumes, snapshots, IPs, total); null: could not be worked out (no price list) updatedAt: text("updated_at").notNull(), // ISO }); @@ -1286,6 +1292,24 @@ export const fragnetState = sqliteTable("fragnet_state", { updatedAt: text("updated_at").notNull(), // ISO }); +// ─── Sonarr, Radarr, Prowlarr ────────────────────────────────────────────── + +// How a Sonarr, Radarr or Prowlarr (an integration of type "sonarr", "radarr" or "prowlarr") is right now, one row each, replaced at every read: what it says is wrong with itself, its download +// queue (the first page, and how many there are), its disks, how many wanted items are missing and — Prowlarr — its indexers. A column that is null could not be read, which is not the same as +// none. Read by services/arrSync.ts. +export const arrState = sqliteTable("arr_state", { + integrationId: integer("integration_id") + .primaryKey() + .references(() => integrations.id, { onDelete: "cascade" }), + version: text("version"), + health: text("health").notNull().default("[]"), // JSON: what its own checks found + queue: text("queue"), // JSON { total, items }; null: could not be read (and always null for Prowlarr) + disks: text("disks"), // JSON; null: could not be read + missing: integer("missing"), // null: not read (Prowlarr has none) + indexers: text("indexers"), // JSON, Prowlarr only; null otherwise or when it could not be read + updatedAt: text("updated_at").notNull(), // ISO +}); + // ─── NetBox ───────────────────────────────────────────────────────────────── // How a NetBox (an integration of type "netbox") is right now, one row each, replaced at every read: its version, how many background workers are running, the counts and the IP diff --git a/server/src/index.ts b/server/src/index.ts index b9aa1da..df7bbbf 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -41,6 +41,7 @@ import { initDockerVulnSync } from "./services/dockerVulnSync.js"; import { initHetznerSync } from "./services/hetznerSync.js"; import { initSpeedtestSync } from "./services/speedtestSync.js"; import { initFragnetSync } from "./services/fragnetSync.js"; +import { initArrSync } from "./services/arrSync.js"; import { backfillMetricRollups } from "./services/serverMetrics.js"; import { backfillEndpointHourly } from "./services/endpointChecks.js"; import { initSelfBackupScheduler } from "./services/selfBackupScheduler.js"; @@ -103,6 +104,7 @@ initDockerVulnSync(); initHetznerSync(); initSpeedtestSync(); initFragnetSync(); +initArrSync(); // The hourly and daily figures are built from what is already kept, once, the first time after they were added (in the background: nothing waits for it). void Promise.all([backfillMetricRollups(), backfillEndpointHourly()]).catch((err) => console.error("[history] couldn't build the hourly and daily figures:", err)); diff --git a/server/src/integrations/arr/adapter.ts b/server/src/integrations/arr/adapter.ts new file mode 100644 index 0000000..33cf2e7 --- /dev/null +++ b/server/src/integrations/arr/adapter.ts @@ -0,0 +1,234 @@ +/** + * Sonarr, Radarr and Prowlarr adapter — the three speak the same API (the "*arr" family), so one adapter serves all of them, told which it is. Config: url, apiKey (the application's own: Settings → + * General → Security → API Key; sent as `X-Api-Key`) and optionally insecure. + * + * Reading only: what the application says is wrong with itself (`/health`), its download queue (`/queue`: what is downloading, what is stuck or failed and why), the disks it uses + * (`/diskspace`), how many wanted items are missing (`/wanted/missing`, Sonarr and Radarr) and — for Prowlarr — its indexers and which of them it has switched off after failures (`/indexer`, + * `/indexerstatus`). Nothing is sent but GET requests: no search is started, nothing is grabbed, removed or changed. + * + * Sonarr and Radarr answer under `/api/v3`, Prowlarr under `/api/v1`. Endpoints and field names are from their published OpenAPI files and source (HealthResource, QueueResource, + * DiskSpaceResource, IndexerStatusResource) and have not been checked against live installs here; every field is read defensively. + */ +import { requestJson } from "../httpJson.js"; +import { withDiagLogging } from "../../services/diagLog.js"; + +export type ArrKind = "sonarr" | "radarr" | "prowlarr"; +export const ARR_KINDS: ArrKind[] = ["sonarr", "radarr", "prowlarr"]; +export const ARR_NAMES: Record = { sonarr: "Sonarr", radarr: "Radarr", prowlarr: "Prowlarr" }; + +export interface ArrConfig { + url: string; + apiKey: string; + insecure?: boolean; +} + +export interface ArrHealthIssue { + /** The check that found it ("IndexerStatusCheck", "DownloadClientCheck" …). */ + source: string; + /** ok, notice, warning or error. */ + type: string; + message: string; +} + +export interface ArrQueueItem { + id: number; + title: string; + /** The application's own status of the item: downloading, paused, completed, warning, failed … (lower case). */ + status: string; + /** How the download is judged: ok, warning or error; null when not said. */ + tracked: "ok" | "warning" | "error" | null; + /** downloading, importPending, importBlocked, failedPending, failed, ignored …; null when not said. */ + state: string | null; + /** What it says is wrong (the status messages and the error), when anything. */ + messages: string[]; + size: number | null; + sizeLeft: number | null; + added: string | null; + etaAt: string | null; + protocol: string | null; + client: string | null; + indexer: string | null; +} + +export interface ArrDisk { + path: string; + label: string | null; + free: number; + total: number; +} + +export interface ArrIndexer { + id: number; + name: string; + enabled: boolean; + protocol: string | null; + /** When Prowlarr will try it again, if it has switched it off after failures. */ + disabledTill: string | null; + lastFailure: string | null; +} + +export interface ArrRead { + version: string | null; + health: ArrHealthIssue[]; + /** Null when the queue could not be read. `total` is what the application says there are, `items` the first page of them. */ + queue: { total: number; items: ArrQueueItem[] } | null; + disks: ArrDisk[] | null; + /** Sonarr and Radarr: how many wanted items have no file yet; null when not read. */ + missing: number | null; + /** Prowlarr only. */ + indexers: ArrIndexer[] | null; +} + +export interface ArrAdapter { + ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }>; + read(): Promise; +} + +export const QUEUE_PAGE = 100; + +const obj = (v: unknown): Record => (v !== null && typeof v === "object" && !Array.isArray(v) ? (v as Record) : {}); +const arr = (v: unknown): unknown[] => (Array.isArray(v) ? v : []); +const str = (v: unknown): string | null => (typeof v === "string" && v.trim() !== "" ? v.trim() : null); +const num = (v: unknown): number | null => (typeof v === "number" && Number.isFinite(v) ? v : null); +const iso = (v: unknown): string | null => { + const s = str(v); + return s !== null && Number.isFinite(Date.parse(s)) ? new Date(s).toISOString() : null; +}; + +/** Pure: `/health` — what each check found; anything that is not a list is no findings. */ +export function parseHealth(raw: unknown): ArrHealthIssue[] { + const out: ArrHealthIssue[] = []; + for (const item of arr(raw)) { + const h = obj(item); + const message = str(h.message); + if (!message) continue; + out.push({ source: str(h.source) ?? "Health", type: (str(h.type) ?? "warning").toLowerCase(), message }); + } + return out; +} + +/** Pure: one item of the queue. */ +export function parseQueueItem(raw: unknown): ArrQueueItem | null { + const q = obj(raw); + const id = num(q.id); + if (id === null) return null; + const tracked = str(q.trackedDownloadStatus)?.toLowerCase(); + const messages: string[] = []; + for (const m of arr(q.statusMessages)) { + const title = str(obj(m).title); + const lines = arr(obj(m).messages).map((x) => str(x)).filter((x): x is string => x !== null); + if (lines.length > 0) messages.push(...lines.map((l) => (title ? `${title}: ${l}` : l))); + else if (title) messages.push(title); + } + const error = str(q.errorMessage); + if (error) messages.unshift(error); + return { + id, + title: str(q.title) ?? `#${id}`, + status: (str(q.status) ?? "unknown").toLowerCase(), + tracked: tracked === "ok" || tracked === "warning" || tracked === "error" ? tracked : null, + state: str(q.trackedDownloadState), + messages: [...new Set(messages)].slice(0, 4), + size: num(q.size), + sizeLeft: num(q.sizeleft), + added: iso(q.added), + etaAt: iso(q.estimatedCompletionTime), + protocol: str(q.protocol), + client: str(q.downloadClient), + indexer: str(q.indexer), + }; +} + +/** Pure: a page of `/queue` (`records`, and the total the application says there are). */ +export function parseQueue(raw: unknown): { total: number; items: ArrQueueItem[] } { + const q = obj(raw); + const items = arr(q.records).map(parseQueueItem).filter((i): i is ArrQueueItem => i !== null); + return { total: num(q.totalRecords) ?? items.length, items }; +} + +/** Pure: `/diskspace`. */ +export function parseDisks(raw: unknown): ArrDisk[] { + const out: ArrDisk[] = []; + for (const item of arr(raw)) { + const d = obj(item); + const path = str(d.path); + const free = num(d.freeSpace); + const total = num(d.totalSpace); + if (!path || free === null || total === null) continue; + out.push({ path, label: str(d.label), free, total }); + } + return out; +} + +/** Pure: Prowlarr's indexers with what `/indexerstatus` says of each. */ +export function parseIndexers(indexers: unknown, status: unknown): ArrIndexer[] { + const failing = new Map>(); + for (const s of arr(status)) { + const o = obj(s); + const id = num(o.indexerId); + if (id !== null) failing.set(id, o); + } + const out: ArrIndexer[] = []; + for (const item of arr(indexers)) { + const i = obj(item); + const id = num(i.id); + const name = str(i.name); + if (id === null || !name) continue; + const st = failing.get(id); + out.push({ id, name, enabled: i.enable !== false, protocol: str(i.protocol), disabledTill: iso(st?.disabledTill), lastFailure: iso(st?.mostRecentFailure) }); + } + return out.sort((a, b) => a.name.localeCompare(b.name)); +} + +export function createArrAdapter(kind: ArrKind, config: ArrConfig): ArrAdapter { + const base = `${String(config.url ?? "").trim().replace(/\/+$/, "")}/api/${kind === "prowlarr" ? "v1" : "v3"}`; + const insecure = config.insecure === true; + const headers = { "X-Api-Key": String(config.apiKey ?? "").trim(), Accept: "application/json" }; + const name = ARR_NAMES[kind]; + + async function get(path: string): Promise { + const res = await requestJson(`${base}${path}`, { headers, insecure }); + if (res.status === 401 || res.status === 403) throw new Error(`${name} did not accept the API key (HTTP ${res.status}) — copy it again from Settings → General → Security → API Key`); + if (res.status === 404) throw new Error(`${name} has no API at this address (HTTP 404) — check the address (its own, not a proxy's), and that it is ${name}`); + if (res.status < 200 || res.status >= 300) throw new Error(`${name} error: HTTP ${res.status}`); + if (res.json === null) throw new Error(`${name} answered with something that isn't JSON — is the address its own?`); + return res.json; + } + + const soft = async (run: () => Promise): Promise => { + try { + return await run(); + } catch { + return null; + } + }; + + async function read(): Promise { + // The status and the health must work: they are what says it is there and what is wrong. + const status = obj(await get("/system/status")); + const health = parseHealth(await get("/health")); + const include = kind === "sonarr" ? "&includeUnknownSeriesItems=true" : kind === "radarr" ? "&includeUnknownMovieItems=true" : ""; + const [queue, disks, missing, indexers, indexerStatus] = await Promise.all([ + kind === "prowlarr" ? Promise.resolve(null) : soft(async () => parseQueue(await get(`/queue?page=1&pageSize=${QUEUE_PAGE}${include}`))), + soft(async () => parseDisks(await get("/diskspace"))), + kind === "prowlarr" ? Promise.resolve(null) : soft(async () => num(obj(await get("/wanted/missing?page=1&pageSize=1&monitored=true")).totalRecords)), + kind === "prowlarr" ? soft(() => get("/indexer")) : Promise.resolve(null), + kind === "prowlarr" ? soft(() => get("/indexerstatus")) : Promise.resolve(null), + ]); + return { version: str(status.version), health, queue, disks, missing, indexers: kind === "prowlarr" && indexers !== null ? parseIndexers(indexers, indexerStatus) : null }; + } + + async function ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }> { + const start = Date.now(); + try { + const status = obj(await get("/system/status")); + const app = str(status.appName); + if (app && app.toLowerCase() !== kind) throw new Error(`That is ${app}, not ${name} — add it as the kind it is`); + return { ok: true, latencyMs: Date.now() - start }; + } catch (err) { + return { ok: false, error: err instanceof Error ? err.message : String(err) }; + } + } + + return withDiagLogging(kind, { ping, read }); +} diff --git a/server/src/integrations/fieldSchemas.ts b/server/src/integrations/fieldSchemas.ts index 9014566..87d0b1d 100644 --- a/server/src/integrations/fieldSchemas.ts +++ b/server/src/integrations/fieldSchemas.ts @@ -114,6 +114,21 @@ export const INTEGRATION_FIELDS: Partial str(obj(h).status)).filter((s): s is string => s !== null && HEALTH.has(s)); + if (states.length === 0) return "unknown"; + if (states.includes("unhealthy")) return "unhealthy"; + return states.every((s) => s === "healthy") ? "healthy" : "unknown"; +} + +/** Pure: what a load balancer sends to, one entry for each server (a label selector is listed as the servers it found, or as itself when it found none). */ +export function parseLbTargets(raw: unknown): HetznerLbTarget[] { + const out: HetznerLbTarget[] = []; + for (const item of arr(raw)) { + const t = obj(item); + if (t.type === "server") { + out.push({ kind: "server", serverId: num(obj(t.server).id), label: null, health: targetHealth(t.health_status) }); + } else if (t.type === "ip") { + out.push({ kind: "ip", serverId: null, label: str(obj(t.ip).ip), health: targetHealth(t.health_status) }); + } else if (t.type === "label_selector") { + const selector = str(obj(t.label_selector).selector); + const found = arr(t.targets).map(obj).filter((x) => num(obj(x.server).id) !== null); + if (found.length === 0) out.push({ kind: "label_selector", serverId: null, label: selector, health: targetHealth(t.health_status) }); + for (const f of found) out.push({ kind: "label_selector", serverId: num(obj(f.server).id), label: selector, health: targetHealth(f.health_status) }); + } + } + return out; +} + +/** Pure: the load balancers of one page of /load_balancers. */ +export function parseLoadBalancers(raw: unknown): HetznerLoadBalancer[] { + const out: HetznerLoadBalancer[] = []; + for (const item of arr(obj(raw).load_balancers)) { + const l = obj(item); + const id = num(l.id); + const name = str(l.name); + if (id === null || !name) continue; + const type = obj(l.load_balancer_type); + const locationName = str(obj(l.location).name); + const priced = arr(type.prices).map(obj).find((p) => str(p.location) === locationName); + const net = obj(l.public_net); + out.push({ + id, + name, + type: str(type.name), + location: locationName, + ipv4: str(obj(net.ipv4).ip), + ipv6: str(obj(net.ipv6).ip), + algorithm: str(obj(l.algorithm).type), + services: arr(l.services).length, + targets: parseLbTargets(l.targets), + includedTraffic: num(l.included_traffic), + outgoingTraffic: num(l.outgoing_traffic), + monthlyPrice: price(obj(obj(priced).price_monthly).gross), + }); + } + return out; +} + +/** Pure: the floating IPs of one page of /floating_ips. */ +export function parseFloatingIps(raw: unknown): HetznerFloatingIp[] { + const out: HetznerFloatingIp[] = []; + for (const item of arr(obj(raw).floating_ips)) { + const f = obj(item); + const id = num(f.id); + const ip = str(f.ip); + if (id === null || !ip || (f.type !== "ipv4" && f.type !== "ipv6")) continue; + out.push({ id, name: str(f.name), ip, type: f.type, serverId: num(f.server), location: str(obj(f.home_location).name), description: str(f.description) }); + } + return out; +} + +/** Pure: the certificates of one page of /certificates. */ +export function parseCertificates(raw: unknown): HetznerCertificate[] { + const out: HetznerCertificate[] = []; + for (const item of arr(obj(raw).certificates)) { + const c = obj(item); + const id = num(c.id); + const name = str(c.name); + if (id === null || !name) continue; + const status = obj(c.status); + const after = str(c.not_valid_after); + out.push({ + id, + name, + type: str(c.type) ?? "uploaded", + domains: arr(c.domain_names).map((d) => str(d)).filter((d): d is string => d !== null), + notValidAfter: after !== null && Number.isFinite(Date.parse(after)) ? new Date(after).toISOString() : null, + issuance: str(status.issuance), + renewal: str(status.renewal), + error: str(obj(status.error).message), + usedBy: arr(c.used_by).length, + }); + } + return out; +} + /** Pure: what /pricing says that the cost estimate needs; null when it is not Hetzner's price list. */ export function parsePrices(raw: unknown): HetznerPrices | null { const p = obj(obj(raw).pricing); @@ -214,8 +371,22 @@ export function parsePrices(raw: unknown): HetznerPrices | null { if (monthly !== null && location && type) primaryIps.push({ type, location, monthly }); } } + const floatingIps: HetznerPrices["floatingIps"] = []; + for (const kind of arr(p.floating_ips)) { + const k = obj(kind); + for (const entry of arr(k.prices)) { + const monthly = price(obj(obj(entry).price_monthly).gross); + const location = str(obj(entry).location); + const type = str(k.type); + if (monthly !== null && location && type) floatingIps.push({ type, location, monthly }); + } + } + // An older price list has one price for a floating IP, whatever its kind and place. + const legacy = price(obj(obj(p.floating_ip).price_monthly).gross); + if (floatingIps.length === 0 && legacy !== null) floatingIps.push({ type: "ipv4", location: "*", monthly: legacy }, { type: "ipv6", location: "*", monthly: legacy }); return { currency, + floatingIps, imagePerGb: price(obj(obj(p.image).price_per_gb_month).gross), volumePerGb: price(obj(obj(p.volume).price_per_gb_month).gross), backupPercent: price(obj(p.server_backup).percentage), @@ -258,14 +429,17 @@ export function createHetznerAdapter(config: HetznerConfig): HetznerAdapter { async function read(): Promise { const servers = await all("/servers", parseServers); - const [volumes, snapshots, backups, primaryIps, prices] = await Promise.all([ + const [volumes, snapshots, backups, primaryIps, prices, loadBalancers, floatingIps, certificates] = await Promise.all([ soft(() => all("/volumes", parseVolumes)), soft(() => all("/images?type=snapshot", parseImages)), soft(() => all("/images?type=backup", parseImages)), soft(() => all("/primary_ips", parsePrimaryIps)), soft(async () => parsePrices(await get("/pricing"))), + soft(() => all("/load_balancers", parseLoadBalancers)), + soft(() => all("/floating_ips", parseFloatingIps)), + soft(() => all("/certificates", parseCertificates)), ]); - return { servers, volumes, images: snapshots && backups ? [...snapshots, ...backups] : null, primaryIps, prices }; + return { servers, volumes, images: snapshots && backups ? [...snapshots, ...backups] : null, primaryIps, prices, loadBalancers, floatingIps, certificates }; } async function ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }> { diff --git a/server/src/integrations/registry.ts b/server/src/integrations/registry.ts index 3159250..fa8cd16 100644 --- a/server/src/integrations/registry.ts +++ b/server/src/integrations/registry.ts @@ -24,6 +24,7 @@ import { createNetBoxAdapter } from "./netbox/adapter.js"; import { createHetznerAdapter } from "./hetzner/adapter.js"; import { createSpeedtestAdapter } from "./speedtest/adapter.js"; import { createFragnetAdapter } from "./fragnet/adapter.js"; +import { createArrAdapter } from "./arr/adapter.js"; import { createNextcloudAdapter } from "./nextcloud/adapter.js"; export interface PingableAdapter { @@ -85,6 +86,10 @@ export function createIntegrationAdapter(type: IntegrationType, config: Integrat return createHetznerAdapter(config as any); case "fragnet": return createFragnetAdapter(config as any); + case "sonarr": + case "radarr": + case "prowlarr": + return createArrAdapter(type, config as any); case "netbox": return createNetBoxAdapter(config as any); case "nextcloud": diff --git a/server/src/routes/arr.ts b/server/src/routes/arr.ts new file mode 100644 index 0000000..d1b0994 --- /dev/null +++ b/server/src/routes/arr.ts @@ -0,0 +1,46 @@ +import { Router } from "express"; +import { inArray } from "drizzle-orm"; +import { db } from "../db/client.js"; +import { arrState, integrations } from "../db/schema.js"; +import { requireAuth } from "../auth/middleware.js"; +import { ARR_KINDS, type ArrKind } from "../integrations/arr/adapter.js"; +import { arrProblems, arrSyncStatuses, distinctDisks, isArrFresh, stuckItems, storedOf } from "../services/arrSync.js"; +import { asyncHandler } from "../utils/asyncHandler.js"; + +export const arrRouter = Router(); +arrRouter.use(requireAuth); + +/** Every Sonarr, Radarr and Prowlarr, how it is, from what the last reads stored: what it says is wrong, its queue (with what is stuck), disks, missing items and indexers. Everyone signed in can see it. Nothing here changes anything in them. */ +arrRouter.get("/", asyncHandler(async (_req, res) => { + const [rows, states, statuses] = await Promise.all([ + db.select({ id: integrations.id, type: integrations.type, name: integrations.name, enabled: integrations.enabled, baseUrl: integrations.baseUrl }).from(integrations).where(inArray(integrations.type, ARR_KINDS)).orderBy(integrations.name), + db.select().from(arrState), + arrSyncStatuses(), + ]); + const byId = new Map(states.map((s) => [s.integrationId, s])); + const now = Date.now(); + res.json({ + apps: rows.map((r) => { + const row = byId.get(r.id); + const state = row ? storedOf(row) : null; + const status = statuses[r.id] ?? null; + const fresh = isArrFresh(status ?? undefined, now); + return { + id: r.id, + kind: r.type as ArrKind, + name: r.name, + enabled: r.enabled, + url: r.baseUrl, + status, + fresh, + state: state && { + ...state, + disks: state.disks && distinctDisks(state.disks), + /** The ids of the queue items that are stuck, so the page marks them the way the alert counts them. */ + stuck: stuckItems(state.queue, now).map((i) => i.id), + }, + problems: state && fresh ? arrProblems(r.type as ArrKind, r.id, r.name, state, now) : [], + }; + }), + }); +})); diff --git a/server/src/routes/hetzner.ts b/server/src/routes/hetzner.ts index 618c937..872c6e1 100644 --- a/server/src/routes/hetzner.ts +++ b/server/src/routes/hetzner.ts @@ -3,7 +3,7 @@ import { eq } from "drizzle-orm"; import { db } from "../db/client.js"; import { hetznerState, integrations, servers } from "../db/schema.js"; import { requireAuth } from "../auth/middleware.js"; -import { costOf, hetznerProblems, hetznerSyncStatuses, imagesOf, isHetznerFresh, matchAppServer, serversOf, volumesOf } from "../services/hetznerSync.js"; +import { certificatesOf, costOf, floatingIpsOf, hetznerProblems, hetznerSyncStatuses, imagesOf, isHetznerFresh, loadBalancersOf, matchAppServer, serversOf, trafficForecast, volumesOf, type StateRow } from "../services/hetznerSync.js"; import { getSettings } from "../services/settingsStore.js"; import { asyncHandler } from "../utils/asyncHandler.js"; @@ -20,6 +20,9 @@ const parseIps = (stored: string | null): string[] => { } }; +/** What else of a project the problems look at, from what is stored. */ +const extrasOf = (state: StateRow) => ({ loadBalancers: loadBalancersOf(state), floatingIps: floatingIpsOf(state), certificates: certificatesOf(state) }); + const appServers = async () => (await db.select({ id: servers.id, name: servers.name, ips: servers.ipAddresses }).from(servers)).map((s) => ({ id: s.id, name: s.name, ips: parseIps(s.ips) })); /** Every Hetzner project, how it is, from what the last read stored: its servers (and which of them the app also knows by its agent), volumes, snapshots, cost and what is wrong. Everyone signed in can see it. */ @@ -49,7 +52,11 @@ hetznerRouter.get("/", asyncHandler(async (_req, res) => { fresh, state: state ? { - servers: stored.map((s) => ({ ...s, linked: matchAppServer(s, known) })), + servers: stored.map(({ trafficHistory: _history, ...s }) => ({ ...s, linked: matchAppServer(s, known), forecast: trafficForecast({ ...s, trafficHistory: _history }, now) })), + /** Null when the load balancers could not be listed. */ + loadBalancers: loadBalancersOf(state)?.map((l) => ({ ...l, targets: l.targets.map((t) => ({ ...t, serverName: t.serverId === null ? null : (names.get(t.serverId) ?? null) })) })) ?? null, + floatingIps: floatingIpsOf(state)?.map((f) => ({ ...f, serverName: f.serverId === null ? null : (names.get(f.serverId) ?? null) })) ?? null, + certificates: certificatesOf(state), /** Null when the volumes could not be listed. */ volumes: volumesOf(state)?.map((v) => ({ ...v, serverName: v.serverId === null ? null : (names.get(v.serverId) ?? null) })) ?? null, images: images?.map((i) => ({ ...i, serverName: i.serverId === null ? null : (names.get(i.serverId) ?? null) })) ?? null, @@ -57,7 +64,7 @@ hetznerRouter.get("/", asyncHandler(async (_req, res) => { updatedAt: state.updatedAt, } : null, - problems: state && fresh ? hetznerProblems(r.id, r.name, stored, images, now, settings.healthChecks.backupStaleHours) : [], + problems: state && fresh ? hetznerProblems(r.id, r.name, stored, images, now, settings.healthChecks.backupStaleHours, extrasOf(state)) : [], }; }), }); @@ -91,10 +98,11 @@ hetznerRouter.get("/for-server/:id", asyncHandler(async (req, res) => { integrationName: r.name, fresh, updatedAt: state.updatedAt, - server, + server: (({ trafficHistory: _h, ...rest }) => rest)(server), newestBackup, snapshots: (images ?? []).filter((i) => i.type === "snapshot" && i.serverId === server.id).length, - problems: fresh ? hetznerProblems(r.id, r.name, stored, images, now, settings.healthChecks.backupStaleHours).filter((p) => p.serverId === server.id) : [], + problems: fresh ? hetznerProblems(r.id, r.name, stored, images, now, settings.healthChecks.backupStaleHours, extrasOf(state)).filter((p) => p.serverId === server.id) : [], + forecast: trafficForecast(server, now), }, }); } diff --git a/server/src/routes/integrations.ts b/server/src/routes/integrations.ts index 2169c72..11b2cb0 100644 --- a/server/src/routes/integrations.ts +++ b/server/src/routes/integrations.ts @@ -39,6 +39,7 @@ import { forgetNetBox, syncNetBox } from "../services/netboxSync.js"; import { forgetHetzner, syncHetzner } from "../services/hetznerSync.js"; import { forgetSpeedtest, syncSpeedtest } from "../services/speedtestSync.js"; import { forgetFragnet, syncFragnet } from "../services/fragnetSync.js"; +import { forgetArr, syncArr } from "../services/arrSync.js"; import { forgetNextcloud, syncNextcloud } from "../services/nextcloudSync.js"; import { dockerVulnSyncStatuses, findingsOf, forgetDockerVulns, isDockerVulnFresh, syncDockerVulns } from "../services/dockerVulnSync.js"; import { invalidateAlertsCache } from "../services/alerts.js"; @@ -153,6 +154,7 @@ integrationsRouter.post("/", requireRole("admin"), asyncHandler(async (req, res) if (type === "hetzner") void syncHetzner(created.id).then(() => invalidateAlertsCache()); if (type === "speedtest") void syncSpeedtest(created.id).then(() => invalidateAlertsCache()); if (type === "fragnet") void syncFragnet(created.id).then(() => invalidateAlertsCache()); + if (type === "sonarr" || type === "radarr" || type === "prowlarr") void syncArr(created.id).then(() => invalidateAlertsCache()); if (type === "nextcloud") void syncNextcloud(created.id).then(() => invalidateAlertsCache()); if (type === "dockhand") void syncDockerVulns(created.id).then(() => invalidateAlertsCache()); @@ -268,6 +270,7 @@ integrationsRouter.patch("/:id", requireRole("admin"), asyncHandler(async (req, if (updated.type === "hetzner" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncHetzner(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "speedtest" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncSpeedtest(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "fragnet" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncFragnet(updated.id).then(() => invalidateAlertsCache()); + if ((updated.type === "sonarr" || updated.type === "radarr" || updated.type === "prowlarr") && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncArr(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "nextcloud" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncNextcloud(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "dockhand" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncDockerVulns(updated.id).then(() => invalidateAlertsCache()); @@ -359,6 +362,7 @@ integrationsRouter.delete("/:id", requireRole("admin"), asyncHandler(async (req, if (existing.type === "hetzner") await forgetHetzner(id); if (existing.type === "speedtest") await forgetSpeedtest(id); if (existing.type === "fragnet") await forgetFragnet(id); + if (existing.type === "sonarr" || existing.type === "radarr" || existing.type === "prowlarr") await forgetArr(id); if (existing.type === "nextcloud") await forgetNextcloud(id); if (existing.type === "dockhand") await forgetDockerVulns(id); await db.delete(integrations).where(eq(integrations.id, id)); diff --git a/server/src/services/alerts.ts b/server/src/services/alerts.ts index 7268bf3..a5b67d2 100644 --- a/server/src/services/alerts.ts +++ b/server/src/services/alerts.ts @@ -86,6 +86,9 @@ const SOURCES: Record = { hetzner: { label: "Hetzner", link: "/hetzner" }, speedtest: { label: "Speedtest", link: "/speedtest" }, fragnet: { label: "Fragnet", link: "/game-servers" }, + sonarr: { label: "Sonarr", link: "/media" }, + radarr: { label: "Radarr", link: "/media" }, + prowlarr: { label: "Prowlarr", link: "/media" }, secrets: { label: "Secrets", link: "/secrets" }, domains: { label: "Domains", link: "/dns?view=domains" }, endpoint: { label: "Endpoint", link: "/endpoints" }, @@ -126,8 +129,10 @@ function originOfConditionKey(key: string): { type: string; id: number | null; c if (m) return { type: "dockhand", id: Number(m[1]), category: "services" }; m = /^speedtest-(?:slow|failing):(\d+)/.exec(key); if (m) return { type: "speedtest", id: Number(m[1]), category: "monitoring" }; - m = /^hetzner-(off|stuck|rescue|traffic|backup):(\d+):/.exec(key); - if (m) return { type: "hetzner", id: Number(m[2]), category: m[1] === "traffic" ? "monitoring" : m[1] === "backup" ? "backup" : "services" }; + m = /^hetzner-(off|stuck|rescue|traffic|forecast|backup|lb|cert|fip):(\d+):/.exec(key); + if (m) return { type: "hetzner", id: Number(m[2]), category: m[1] === "traffic" || m[1] === "forecast" ? "monitoring" : m[1] === "backup" ? "backup" : "services" }; + m = /^(sonarr|radarr|prowlarr)-(health|queue|disk):(\d+)/.exec(key); + if (m) return { type: m[1], id: Number(m[3]), category: m[2] === "disk" ? "disk" : "services" }; m = /^fragnet-(disk|memory|backup):(\d+):/.exec(key); if (m) return { type: "fragnet", id: Number(m[2]), category: m[1] === "disk" ? "disk" : m[1] === "backup" ? "backup" : "monitoring" }; m = /^duplicati-(?:failed|stale):(\d+)/.exec(key); @@ -270,7 +275,7 @@ export async function collectAlerts(): Promise { type: origin.type, message: c.message, key: c.key, - link: origin.type === "server" && origin.id !== null ? `/servers/${origin.id}${/^(failed-units|smart|zfs):/.test(c.key) ? "?view=health" : c.key.startsWith("new-port:") ? "?view=network" : c.key.startsWith("rule:") || c.key.startsWith("baseline:") ? "?view=history" : ""}` : origin.type === "unifi" ? "/network/devices" : origin.type === "ups" ? "/ups" : origin.type === "slo" ? "/service-levels" : origin.type === "dockhand" ? "/docker" : origin.type === "duplicati" ? "/duplicati" : origin.type === "jellyfin" ? "/jellyfin" : origin.type === "authentik" ? "/authentik" : origin.type === "prometheus" ? "/prometheus" : origin.type === "immich" ? "/immich" : origin.type === "paperless" ? "/paperless" : origin.type === "nextcloud" ? "/nextcloud" : origin.type === "netbox" ? "/netbox" : origin.type === "n8n" ? "/n8n" : origin.type === "hetzner" ? "/hetzner" : origin.type === "speedtest" ? "/speedtest" : origin.type === "fragnet" ? "/game-servers" : undefined, + link: origin.type === "server" && origin.id !== null ? `/servers/${origin.id}${/^(failed-units|smart|zfs):/.test(c.key) ? "?view=health" : c.key.startsWith("new-port:") ? "?view=network" : c.key.startsWith("rule:") || c.key.startsWith("baseline:") ? "?view=history" : ""}` : origin.type === "unifi" ? "/network/devices" : origin.type === "ups" ? "/ups" : origin.type === "slo" ? "/service-levels" : origin.type === "dockhand" ? "/docker" : origin.type === "duplicati" ? "/duplicati" : origin.type === "jellyfin" ? "/jellyfin" : origin.type === "authentik" ? "/authentik" : origin.type === "prometheus" ? "/prometheus" : origin.type === "immich" ? "/immich" : origin.type === "paperless" ? "/paperless" : origin.type === "nextcloud" ? "/nextcloud" : origin.type === "netbox" ? "/netbox" : origin.type === "n8n" ? "/n8n" : origin.type === "hetzner" ? "/hetzner" : origin.type === "speedtest" ? "/speedtest" : origin.type === "fragnet" ? "/game-servers" : origin.type === "sonarr" || origin.type === "radarr" || origin.type === "prowlarr" ? "/media" : undefined, silenced: subject !== null && subjects.has(subject), target: targetOfSubject(subject), }); } @@ -280,7 +285,7 @@ export async function collectAlerts(): Promise { if (held.has("slo")) cannotCheck("Service-level targets", "couldn't be judged — see the server log", "Server and storage health"); if (held.has("server:baseline")) cannotCheck("What is usual for the time", "couldn't be judged — see the server log", "Server and storage health"); for (const h of held) { - const m = /^(proxmox|synology|unifi|ups|dockhand|jellyfin|authentik|prometheus|immich|paperless|nextcloud|netbox|n8n|hetzner|speedtest|fragnet):(\d+)(?::(.+))?$/.exec(h); + const m = /^(proxmox|synology|unifi|ups|dockhand|jellyfin|authentik|prometheus|immich|paperless|nextcloud|netbox|n8n|hetzner|speedtest|fragnet|sonarr|radarr|prowlarr):(\d+)(?::(.+))?$/.exec(h); if (!m || (m[3] && held.has(`${m[1]}:${m[2]}`))) continue; const row = intById.get(Number(m[2])); cannotCheck(`${SOURCES[m[1]].label} “${row?.name ?? `#${m[2]}`}”${m[3] === "vuln" ? " (vulnerability scans)" : m[3] ? ` (node ${m[3]})` : ""}`, "couldn't be read — see the Diagnostic Log", "Server and storage health"); diff --git a/server/src/services/arrSync.ts b/server/src/services/arrSync.ts new file mode 100644 index 0000000..0dfa39e --- /dev/null +++ b/server/src/services/arrSync.ts @@ -0,0 +1,227 @@ +/** + * Keeps what Sonarr, Radarr and Prowlarr say up to date: every five minutes each one is read — what its own checks found wrong, its download queue, its disks, how many wanted items are + * missing and (Prowlarr) its indexers — and the state is stored. Pages and alerts are built from what is stored, so none of them talks to the applications. + * + * What is raised: **what the application itself says is wrong** (its health checks of type warning or error: a download client that cannot be reached, indexers switched off after failures, a + * root folder gone — a mere notice, such as an update being available, is not raised); **downloads that are stuck** — in the queue for two hours or more and judged warning or error, or failed, + * or blocked from importing (one alert for the lot, naming the first few); **a disk nearly full** (under 10% free, critical under 5%). The same three for each of the three, under one key each. + */ +import { and, eq, inArray } from "drizzle-orm"; +import { db } from "../db/client.js"; +import { arrState, integrations } from "../db/schema.js"; +import { ARR_KINDS, ARR_NAMES, createArrAdapter, type ArrDisk, type ArrHealthIssue, type ArrIndexer, type ArrKind, type ArrQueueItem, type ArrRead } from "../integrations/arr/adapter.js"; +import { loadIntegrationConfig } from "../integrations/loadIntegration.js"; +import { getInternalFlag, setInternalFlag } from "./settingsStore.js"; + +export const SYNC_INTERVAL_MS = 5 * 60_000; +/** After this long without a good read, what is stored is no longer believed. */ +export const STALE_AFTER_MS = 20 * 60_000; +const STATUS_FLAG = "arrSync"; + +const MIN = 60_000; +const HOUR = 60 * MIN; +/** A download judged wrong for less than this is left to sort itself out (a client that is just slow to answer). */ +export const STUCK_AFTER_MS = 2 * HOUR; +export const DISK_WARN_FREE = 0.1; +export const DISK_CRITICAL_FREE = 0.05; +/** A disk smaller than this is not a media disk (a tmpfs, a boot partition). */ +export const MIN_DISK_BYTES = 2 * 1024 ** 3; + +export interface ArrSyncStatus { + /** The last read that worked (kept when a later one failed). */ + at: string; + ok: boolean; + error: string | null; +} + +async function readStatuses(): Promise> { + try { + const raw = await getInternalFlag(STATUS_FLAG); + return raw ? (JSON.parse(raw) as Record) : {}; + } catch { + return {}; + } +} + +export async function arrSyncStatuses(): Promise> { + return Object.fromEntries(Object.entries(await readStatuses()).map(([k, v]) => [Number(k), v])); +} + +export const isArrFresh = (status: ArrSyncStatus | undefined, nowMs: number) => !!status && status.ok && nowMs - Date.parse(status.at) <= STALE_AFTER_MS; + +export type StateRow = typeof arrState.$inferSelect; + +function parse(stored: string | null): T | null { + if (stored === null) return null; + try { + return JSON.parse(stored) as T; + } catch { + return null; + } +} + +/** What is stored of one application, as the read gave it. */ +export interface StoredArr { + version: string | null; + health: ArrHealthIssue[]; + queue: { total: number; items: ArrQueueItem[] } | null; + disks: ArrDisk[] | null; + missing: number | null; + indexers: ArrIndexer[] | null; + updatedAt: string; +} + +export const storedOf = (row: StateRow): StoredArr => ({ + version: row.version, + health: parse(row.health) ?? [], + queue: parse<{ total: number; items: ArrQueueItem[] }>(row.queue), + disks: parse(row.disks), + missing: row.missing, + indexers: parse(row.indexers), + updatedAt: row.updatedAt, +}); + +/** Writes down one read, replacing the last. */ +export async function storeRead(integrationId: number, r: ArrRead, now: Date = new Date()): Promise { + const values = { + version: r.version, + health: JSON.stringify(r.health), + queue: r.queue && JSON.stringify(r.queue), + disks: r.disks && JSON.stringify(r.disks), + missing: r.missing, + indexers: r.indexers && JSON.stringify(r.indexers), + updatedAt: now.toISOString(), + }; + await db.insert(arrState).values({ integrationId, ...values }).onConflictDoUpdate({ target: arrState.integrationId, set: values }); +} + +/** Reads one application and stores it. Never throws: how it went is the answer, and what was stored is left alone when it failed. */ +export async function syncArr(integrationId: number, now: Date = new Date(), read?: (kind: ArrKind, config: Record) => Promise): Promise { + let status: ArrSyncStatus; + try { + const loaded = await loadIntegrationConfig(integrationId); + const kind = loaded?.integration.type as ArrKind | undefined; + if (!loaded || !kind || !ARR_KINDS.includes(kind)) throw new Error("not a Sonarr, Radarr or Prowlarr integration"); + const result = await (read ? read(kind, loaded.config) : createArrAdapter(kind, loaded.config as never).read()); + await storeRead(integrationId, result, now); + status = { at: now.toISOString(), ok: true, error: null }; + } catch (err) { + const previous = (await readStatuses())[String(integrationId)]; + status = { at: previous?.at ?? now.toISOString(), ok: false, error: err instanceof Error ? err.message : String(err) }; + console.error(`[arr] couldn't read integration ${integrationId}:`, status.error); + } + try { + const all = await readStatuses(); + all[String(integrationId)] = status; + await setInternalFlag(STATUS_FLAG, JSON.stringify(all)); + } catch (err) { + console.error("[arr] couldn't record the result:", err); + } + return status; +} + +export async function syncAllArr(now: Date = new Date()): Promise> { + const rows = await db.select({ id: integrations.id }).from(integrations).where(and(inArray(integrations.type, ARR_KINDS), eq(integrations.enabled, true))); + const out: Record = {}; + for (const r of rows) out[r.id] = await syncArr(r.id, now); + return out; +} + +export async function forgetArr(integrationId: number): Promise { + const all = await readStatuses(); + if (String(integrationId) in all) { + delete all[String(integrationId)]; + await setInternalFlag(STATUS_FLAG, JSON.stringify(all)); + } +} + +// ─── What is wrong ────────────────────────────────────────────────────────── + +export interface ArrProblem { + key: string; + message: string; + severity: "warning" | "critical"; +} + +const slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40); + +/** A short stable stamp of a message, numbers left out (so "3 indexers" and "4 indexers" are the same finding). */ +function stamp(message: string): string { + let h = 0; + for (const c of message.replace(/\d+/g, "#")) h = (h * 31 + c.charCodeAt(0)) >>> 0; + return h.toString(36); +} + +export const sizeText = (bytes: number): string => { + const gb = bytes / 1024 ** 3; + return gb >= 1024 ? `${(gb / 1024).toFixed(1)} TB` : `${gb.toFixed(gb >= 100 ? 0 : 1)} GB`; +}; + +/** A finding starts with a capital as a sentence of its own; after "says" it reads better without ("No download client" → "no download client"), unless it starts with a name or an acronym. */ +const lcFirst = (s: string) => (/^[A-Z][a-z]/.test(s) ? s[0].toLowerCase() + s.slice(1) : s); + +const plural = (n: number, unit: string) => `${n} ${unit}${n === 1 ? "" : "s"}`; +const ago = (ms: number): string => (ms >= 48 * HOUR ? plural(Math.round(ms / (24 * HOUR)), "day") : ms >= HOUR ? plural(Math.round(ms / HOUR), "hour") : plural(Math.max(1, Math.round(ms / MIN)), "minute")); + +/** Pure: whether a queue item is stuck — judged wrong, or failed, or blocked from importing — and has been in the queue long enough for it not to sort itself out. */ +export function isStuck(i: ArrQueueItem, nowMs: number): boolean { + const bad = i.tracked === "warning" || i.tracked === "error" || i.state === "failed" || i.state === "failedPending" || i.state === "importBlocked" || i.status === "failed"; + if (!bad) return false; + const since = i.added === null ? null : nowMs - Date.parse(i.added); + return since !== null && since >= STUCK_AFTER_MS; +} + +/** Pure: the stuck items, longest in the queue first. */ +export const stuckItems = (queue: StoredArr["queue"], nowMs: number): ArrQueueItem[] => (queue?.items ?? []).filter((i) => isStuck(i, nowMs)).sort((a, b) => Date.parse(a.added ?? "") - Date.parse(b.added ?? "")); + +/** Pure: the disks worth judging — one for each filesystem (the same size and free space is the same disk, however many folders are on it). */ +export function distinctDisks(disks: ArrDisk[] | null): ArrDisk[] { + const seen = new Set(); + const out: ArrDisk[] = []; + for (const d of [...(disks ?? [])].sort((a, b) => a.path.length - b.path.length || a.path.localeCompare(b.path))) { + if (d.total < MIN_DISK_BYTES) continue; + const id = `${d.total}:${d.free}`; + if (seen.has(id)) continue; + seen.add(id); + out.push(d); + } + return out; +} + +/** Pure: what is wrong with one application, from what is stored for it. */ +export function arrProblems(kind: ArrKind, id: number, name: string, state: StoredArr, nowMs: number): ArrProblem[] { + const out: ArrProblem[] = []; + const app = ARR_NAMES[kind]; + for (const h of state.health) { + if (h.type !== "warning" && h.type !== "error") continue; + out.push({ key: `${kind}-health:${id}:${slug(h.source)}-${stamp(h.message)}`, severity: "warning", message: `${name}: ${app} says ${lcFirst(h.message.trim())}` }); + } + const stuck = stuckItems(state.queue, nowMs); + if (stuck.length > 0) { + const names = stuck.slice(0, 3).map((i) => i.title); + const oldest = stuck[0].added === null ? null : nowMs - Date.parse(stuck[0].added); + const why = stuck[0].messages[0]; + out.push({ + key: `${kind}-queue:${id}`, + severity: "warning", + message: `${name}: ${plural(stuck.length, "download")} ${stuck.length === 1 ? "is" : "are"} stuck — ${names.join("; ")}${stuck.length > 3 ? `; and ${stuck.length - 3} more` : ""}${oldest !== null ? ` (the oldest for ${ago(oldest)})` : ""}${why ? ` — ${why}` : ""}`, + }); + } + for (const d of distinctDisks(state.disks)) { + const free = d.free / d.total; + if (free < DISK_WARN_FREE) { + out.push({ key: `${kind}-disk:${id}:${slug(d.path)}`, severity: free < DISK_CRITICAL_FREE ? "critical" : "warning", message: `${name}: ${d.path} has ${sizeText(d.free)} free of ${sizeText(d.total)} (${Math.floor(free * 100)}%)` }); + } + } + return out; +} + +let timer: ReturnType | null = null; + +export function initArrSync(): void { + if (timer) return; + const pass = () => void syncAllArr().catch((err) => console.error("[arr] pass failed:", err)); + timer = setInterval(pass, SYNC_INTERVAL_MS); + setTimeout(pass, 37_000); + console.log(`[arr] reading Sonarr, Radarr and Prowlarr every ${SYNC_INTERVAL_MS / 60000} minutes`); +} diff --git a/server/src/services/healthMonitor.ts b/server/src/services/healthMonitor.ts index e8c90df..5cd31e3 100644 --- a/server/src/services/healthMonitor.ts +++ b/server/src/services/healthMonitor.ts @@ -1,6 +1,6 @@ -import { and, eq } from "drizzle-orm"; +import { and, eq, inArray } from "drizzle-orm"; import { db } from "../db/client.js"; -import { authentikState, n8nState, netboxState, nextcloudState, paperlessState, immichState, prometheusState, integrations, jellyfinState, networkDevices, serverPorts, servers, upsState , dockhandVulnerabilities , hetznerState , fragnetState } from "../db/schema.js"; +import { authentikState, n8nState, netboxState, nextcloudState, paperlessState, immichState, prometheusState, integrations, jellyfinState, networkDevices, serverPorts, servers, upsState , dockhandVulnerabilities , hetznerState , fragnetState , arrState } from "../db/schema.js"; import { loadIntegrationConfig } from "../integrations/loadIntegration.js"; import { createProxmoxAdapter, type ProxmoxNodeStats } from "../integrations/proxmox/adapter.js"; import { createSynologyAdapter, type SynologyStorageInfo } from "../integrations/synology/adapter.js"; @@ -30,7 +30,9 @@ import { isNetBoxFresh, netboxProblems, netboxSyncStatuses, type NetBoxProblem } import { isNextcloudFresh, nextcloudProblems, nextcloudSyncStatuses, type NextcloudProblem } from "./nextcloudSync.js"; import { dockerVulnProblems, dockerVulnSyncStatuses, isDockerVulnFresh, type DockerVulnProblem } from "./dockerVulnSync.js"; import { expectedOf as speedtestExpected, isSpeedtestFresh, recentResults as recentSpeedtestResults, speedtestProblems, speedtestSyncStatuses, type SpeedtestProblem } from "./speedtestSync.js"; -import { hetznerProblems, hetznerSyncStatuses, imagesOf as hetznerImagesOf, isHetznerFresh, serversOf as hetznerServersOf, type HetznerProblem } from "./hetznerSync.js"; +import { hetznerProblems, hetznerSyncStatuses, imagesOf as hetznerImagesOf, loadBalancersOf as hetznerLoadBalancersOf, floatingIpsOf as hetznerFloatingIpsOf, certificatesOf as hetznerCertificatesOf, isHetznerFresh, serversOf as hetznerServersOf, type HetznerProblem } from "./hetznerSync.js"; +import { ARR_KINDS, type ArrKind } from "../integrations/arr/adapter.js"; +import { arrProblems, arrSyncStatuses, isArrFresh, storedOf as arrStoredOf, type ArrProblem } from "./arrSync.js"; import { fragnetProblems, fragnetSyncStatuses, isFragnetFresh, optionsOf as fragnetOptions, serversOf as fragnetServersOf, type FragnetProblem } from "./fragnetSync.js"; import { evaluateContainers, loadContainerMemory, saveContainerMemory, type ContainerMemory, type DockerSnapshot } from "./containerHealth.js"; import { recordStorageSamples } from "./storageHistory.js"; @@ -128,6 +130,8 @@ export interface HealthSnapshot { speedtest?: { integrationId: number; problems: SpeedtestProblem[] }[]; /** What is wrong with each Fragnet game panel account (a backup that is late, a disk or memory nearly full), only while that reading is recent (services/fragnetSync.ts). */ fragnet?: { integrationId: number; problems: FragnetProblem[] }[]; + /** What is wrong with each Sonarr, Radarr and Prowlarr (what it says itself, downloads that are stuck, a disk nearly full), only while that reading is recent (services/arrSync.ts). */ + arr?: { integrationId: number; kind: ArrKind; problems: ArrProblem[] }[]; /** Containers to leave alone. */ dockerIgnore?: string[]; /** The clock the container judgements are made on (the pass's, so a test can set it). */ @@ -269,6 +273,9 @@ export function evaluateHealth(snapshot: HealthSnapshot, thresholds: Thresholds, // Speedtest Tracker: the internet slower than it is sold at, speed tests that keep failing. for (const s of snapshot.speedtest ?? []) for (const p of s.problems) out.push({ key: p.key, source: `speedtest:${s.integrationId}`, message: p.message, severity: p.severity }); + // Sonarr, Radarr and Prowlarr: what they say is wrong, downloads that are stuck, disks nearly full. + for (const a of snapshot.arr ?? []) for (const p of a.problems) out.push({ key: p.key, source: `${a.kind}:${a.integrationId}`, message: p.message, severity: p.severity }); + // Fragnet game servers: backups that are late, disks and memory nearly full. for (const f of snapshot.fragnet ?? []) for (const p of f.problems) out.push({ key: p.key, source: `fragnet:${f.integrationId}`, message: p.message, severity: p.severity }); @@ -537,6 +544,24 @@ export async function collectSnapshot(): Promise<{ snapshot: HealthSnapshot; hel console.error("[health] couldn't judge Speedtest Tracker:", err instanceof Error ? err.message : err); } + // Sonarr, Radarr and Prowlarr: read by their own pass every five minutes; what is judged is what that pass stored, and only while it is recent. + try { + const rowsA = await db.select({ id: integrations.id, name: integrations.name, type: integrations.type }).from(integrations).where(and(inArray(integrations.type, ARR_KINDS), eq(integrations.enabled, true))); + if (rowsA.length > 0) { + const statuses = await arrSyncStatuses(); + for (const r of rowsA) { + const [state] = await db.select().from(arrState).where(eq(arrState.integrationId, r.id)).limit(1); + if (!state || !isArrFresh(statuses[r.id], Date.now())) { + held.add(`${r.type}:${r.id}`); + continue; + } + (snapshot.arr ??= []).push({ integrationId: r.id, kind: r.type as ArrKind, problems: arrProblems(r.type as ArrKind, r.id, r.name, arrStoredOf(state), Date.now()) }); + } + } + } catch (err) { + console.error("[health] couldn't judge Sonarr, Radarr and Prowlarr:", err instanceof Error ? err.message : err); + } + // Fragnet game servers: read by its own pass every five minutes; what is judged is what that pass stored, and only while it is recent. try { const rowsF = await db.select({ id: integrations.id, name: integrations.name }).from(integrations).where(and(eq(integrations.type, "fragnet"), eq(integrations.enabled, true))); @@ -567,7 +592,7 @@ export async function collectSnapshot(): Promise<{ snapshot: HealthSnapshot; hel held.add(`hetzner:${r.id}`); continue; } - (snapshot.hetzner ??= []).push({ integrationId: r.id, problems: hetznerProblems(r.id, r.name, hetznerServersOf(state), hetznerImagesOf(state), Date.now(), checks.backupStaleHours) }); + (snapshot.hetzner ??= []).push({ integrationId: r.id, problems: hetznerProblems(r.id, r.name, hetznerServersOf(state), hetznerImagesOf(state), Date.now(), checks.backupStaleHours, { loadBalancers: hetznerLoadBalancersOf(state), floatingIps: hetznerFloatingIpsOf(state), certificates: hetznerCertificatesOf(state) }) }); } } } catch (err) { diff --git a/server/src/services/hetznerSync.ts b/server/src/services/hetznerSync.ts index 34133aa..fd3bf94 100644 --- a/server/src/services/hetznerSync.ts +++ b/server/src/services/hetznerSync.ts @@ -10,7 +10,7 @@ import { and, eq } from "drizzle-orm"; import { db } from "../db/client.js"; import { hetznerState, integrations } from "../db/schema.js"; -import { createHetznerAdapter, type HetznerImage, type HetznerRead, type HetznerServer, type HetznerVolume } from "../integrations/hetzner/adapter.js"; +import { createHetznerAdapter, type HetznerCertificate, type HetznerFloatingIp, type HetznerImage, type HetznerLoadBalancer, type HetznerRead, type HetznerServer, type HetznerVolume } from "../integrations/hetzner/adapter.js"; import { loadIntegrationConfig } from "../integrations/loadIntegration.js"; import { getInternalFlag, setInternalFlag } from "./settingsStore.js"; @@ -28,6 +28,17 @@ export const STUCK_AFTER_MS = 30 * MIN; /** Rescue mode switched on and not used within this long: the next reboot would come up in it. */ export const RESCUE_AFTER_MS = HOUR; export const TRAFFIC_WARN = 0.8; +const DAY = 24 * HOUR; +/** A certificate this close to its end is a warning; this close (or past it) is critical. */ +export const CERT_WARN_DAYS = 14; +export const CERT_CRITICAL_DAYS = 3; +/** The traffic of a server is written down about this often (more reads than that are not kept), for the last two weeks. */ +export const TRAFFIC_SAMPLE_EVERY_MS = 6 * HOUR; +export const TRAFFIC_SAMPLE_KEEP_MS = 14 * DAY; +/** A forecast needs this much of the month behind it (by the month's average), or this much of the last week (by the recent rate). */ +export const FORECAST_MIN_MONTH_MS = 3 * DAY; +export const FORECAST_MIN_RECENT_MS = 2 * DAY; +export const FORECAST_RECENT_WINDOW_MS = 7 * DAY; export interface HetznerSyncStatus { /** The last read that worked (kept when a later one failed). */ @@ -61,6 +72,13 @@ export interface StoredServer extends HetznerServer { statusSince: string; /** When the first read that showed rescue mode on was made; null when it is not on. */ rescueSince: string | null; + /** The month's outgoing traffic as it was now and then (about every six hours, for two weeks, starting over when the counter goes down — a new month); what the forecast is made from. */ + trafficHistory?: TrafficSample[]; +} + +export interface TrafficSample { + at: string; + bytes: number; } export interface HetznerCost { @@ -70,6 +88,9 @@ export interface HetznerCost { volumes: number; snapshots: number; ips: number; + /** Load balancers and floating IPs (absent in an estimate stored before they were read). */ + loadBalancers?: number; + floatingIps?: number; total: number; /** Primary IPs that belong to no server (billed all the same). */ unassignedIps: number; @@ -90,6 +111,9 @@ const parseList = (stored: string | null): T[] | null => { export const serversOf = (row: Pick): StoredServer[] => parseList(row.servers) ?? []; export const volumesOf = (row: Pick): HetznerVolume[] | null => parseList(row.volumes); export const imagesOf = (row: Pick): HetznerImage[] | null => parseList(row.images); +export const loadBalancersOf = (row: Pick): HetznerLoadBalancer[] | null => parseList(row.loadBalancers); +export const floatingIpsOf = (row: Pick): HetznerFloatingIp[] | null => parseList(row.floatingIps); +export const certificatesOf = (row: Pick): HetznerCertificate[] | null => parseList(row.certificates); export const costOf = (row: Pick): HetznerCost | null => { if (!row.cost) return null; try { @@ -99,6 +123,55 @@ export const costOf = (row: Pick): HetznerCost | null => { } }; +/** Pure: the traffic history with this read added (one sample about every six hours); a counter that went down is a new month, so the history starts over; old samples are dropped. */ +export function carryTraffic(bytes: number | null, history: TrafficSample[], now: Date): TrafficSample[] { + if (bytes === null) return history; + const nowMs = now.getTime(); + let kept = history.filter((h) => nowMs - Date.parse(h.at) <= TRAFFIC_SAMPLE_KEEP_MS); + const last = kept[kept.length - 1]; + if (last && bytes < last.bytes) kept = []; + const newest = kept[kept.length - 1]; + if (!newest || nowMs - Date.parse(newest.at) >= TRAFFIC_SAMPLE_EVERY_MS) kept = [...kept, { at: now.toISOString(), bytes }]; + return kept; +} + +export interface TrafficForecast { + /** Bytes a day, the way it has been going. */ + perDay: number; + /** What the month will have come to by its end at that rate. */ + projectedMonth: number; + /** When the quota is passed, if it is before the month ends; null when it is not (or already has been). */ + exhaustedAt: string | null; + /** Whether the rate is the last week's or the month's average. */ + basis: "recent" | "month"; +} + +/** + * Pure: how the month's traffic is going to end, by the rate of the last week (or, with too little of it, the month's average so far) — null when there is too little to say anything. The + * month is taken to be the calendar month in UTC, which is how Hetzner counts it (not checked against a live project: a counter that goes down starts the history over anyway). + */ +export function trafficForecast(s: Pick, nowMs: number): TrafficForecast | null { + const used = s.outgoingTraffic; + const included = s.includedTraffic; + if (used === null || included === null || included <= 0 || used <= 0) return null; + const d = new Date(nowMs); + const monthStart = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1); + const monthEnd = Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 1); + let perDay: number | null = null; + let basis: TrafficForecast["basis"] = "recent"; + const window = (s.trafficHistory ?? []).filter((h) => Date.parse(h.at) >= Math.max(monthStart, nowMs - FORECAST_RECENT_WINDOW_MS) && h.bytes <= used); + const oldest = window[0]; + if (oldest && nowMs - Date.parse(oldest.at) >= FORECAST_MIN_RECENT_MS) perDay = ((used - oldest.bytes) / (nowMs - Date.parse(oldest.at))) * DAY; + if (perDay === null && nowMs - monthStart >= FORECAST_MIN_MONTH_MS) { + perDay = (used / (nowMs - monthStart)) * DAY; + basis = "month"; + } + if (perDay === null) return null; + const projectedMonth = used + (perDay * (monthEnd - nowMs)) / DAY; + const exhaustedAt = used < included && projectedMonth > included && perDay > 0 ? new Date(nowMs + ((included - used) / perDay) * DAY).toISOString() : null; + return { perDay, projectedMonth, exhaustedAt, basis }; +} + /** Pure: what the app has seen between reads, carried from the last read of the same server. A server first seen starts its clocks now. */ export function carryTimes(servers: HetznerServer[], previous: StoredServer[], now: Date): StoredServer[] { const before = new Map(previous.map((p) => [p.id, p])); @@ -107,6 +180,7 @@ export function carryTimes(servers: HetznerServer[], previous: StoredServer[], n const p = before.get(s.id); return { ...s, + trafficHistory: carryTraffic(s.outgoingTraffic, p?.trafficHistory ?? [], now), lastRunningAt: s.status === "running" ? at : (p?.lastRunningAt ?? null), statusSince: p && p.status === s.status ? p.statusSince : at, rescueSince: s.rescueEnabled ? (p?.rescueEnabled ? (p.rescueSince ?? at) : at) : null, @@ -115,7 +189,7 @@ export function carryTimes(servers: HetznerServer[], previous: StoredServer[], n } /** Pure: roughly what the project costs per month at Hetzner's list prices, including VAT; null when the price list could not be read. Load balancers, floating IPs and traffic over the quota are not in it. */ -export function estimateCost(read: Pick): HetznerCost | null { +export function estimateCost(read: Pick & Partial>): HetznerCost | null { const p = read.prices; if (!p) return null; let servers = 0; @@ -137,9 +211,21 @@ export function estimateCost(read: Pick x.type === ip.type && x.location === ip.location)?.monthly ?? 0; if (!ip.assigned) unassignedIps++; } + let loadBalancers = 0; + for (const lb of read.loadBalancers ?? []) { + if (lb.monthlyPrice === null) unpriced++; + else loadBalancers += lb.monthlyPrice; + } + let floatingIps = 0; + for (const f of read.floatingIps ?? []) { + const prices = p.floatingIps ?? []; + const found = prices.find((x) => x.type === f.type && x.location === f.location) ?? prices.find((x) => x.type === f.type && x.location === "*"); + if (found) floatingIps += found.monthly; + else unpriced++; + } const round = (n: number) => Math.round(n * 100) / 100; - const parts = { servers: round(servers), backups: round(backups), volumes: round(volumes), snapshots: round(snapshots), ips: round(ips) }; - return { currency: p.currency, ...parts, total: round(servers + backups + volumes + snapshots + ips), unassignedIps, unpriced }; + const parts = { servers: round(servers), backups: round(backups), volumes: round(volumes), snapshots: round(snapshots), ips: round(ips), loadBalancers: round(loadBalancers), floatingIps: round(floatingIps) }; + return { currency: p.currency, ...parts, total: round(servers + backups + volumes + snapshots + ips + loadBalancers + floatingIps), unassignedIps, unpriced }; } /** Writes down one read, replacing the last (and carrying what was seen between reads). */ @@ -149,6 +235,9 @@ export async function storeRead(integrationId: number, r: HetznerRead, now: Date servers: JSON.stringify(carryTimes(r.servers, previous ? serversOf(previous) : [], now)), volumes: r.volumes && JSON.stringify(r.volumes), images: r.images && JSON.stringify(r.images), + loadBalancers: r.loadBalancers && JSON.stringify(r.loadBalancers), + floatingIps: r.floatingIps && JSON.stringify(r.floatingIps), + certificates: r.certificates && JSON.stringify(r.certificates), cost: ((c) => c && JSON.stringify(c))(estimateCost(r)), updatedAt: now.toISOString(), }; @@ -204,6 +293,20 @@ export interface HetznerProblem { severity: "warning" | "critical"; } +/** What else of a project the problems look at: each is null when it could not be read, which says nothing is wrong. */ +export interface HetznerExtras { + loadBalancers?: HetznerLoadBalancer[] | null; + floatingIps?: HetznerFloatingIp[] | null; + certificates?: HetznerCertificate[] | null; +} + +const MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; +/** "24 June", in UTC (Hetzner's month is). */ +export const dayText = (iso: string): string => { + const d = new Date(iso); + return `${d.getUTCDate()} ${MONTHS[d.getUTCMonth()]}`; +}; + /** In the units the pages show (binary, written GB or TB), so an alert and the tile beside it agree. */ export const sizeText = (bytes: number): string => { const gb = bytes / 1024 ** 3; @@ -216,7 +319,7 @@ const ago = (ms: number): string => (ms >= 48 * HOUR ? plural(Math.round(ms / (2 /** * Pure: what is wrong with one project, from what is stored for it. `backupStaleHours` is the same limit as for Proxmox guests' backups (0 = not judged). */ -export function hetznerProblems(id: number, name: string, servers: StoredServer[], images: HetznerImage[] | null, nowMs: number, backupStaleHours: number): HetznerProblem[] { +export function hetznerProblems(id: number, name: string, servers: StoredServer[], images: HetznerImage[] | null, nowMs: number, backupStaleHours: number, extras: HetznerExtras = {}): HetznerProblem[] { const out: HetznerProblem[] = []; for (const s of [...servers].sort((a, b) => a.name.localeCompare(b.name))) { const since = nowMs - Date.parse(s.statusSince); @@ -230,6 +333,15 @@ export function hetznerProblems(id: number, name: string, servers: StoredServer[ } if (s.includedTraffic !== null && s.includedTraffic > 0 && s.outgoingTraffic !== null) { const used = s.outgoingTraffic / s.includedTraffic; + const forecast = used < TRAFFIC_WARN ? trafficForecast(s, nowMs) : null; + if (forecast?.exhaustedAt) { + out.push({ + key: `hetzner-forecast:${id}:${s.id}`, + serverId: s.id, + severity: "warning", + message: `${name}: at this rate ${s.name} will pass its ${sizeText(s.includedTraffic)} traffic quota on ${dayText(forecast.exhaustedAt)} — it has sent ${sizeText(s.outgoingTraffic)} so far, about ${sizeText(forecast.perDay)} a day (${forecast.basis === "recent" ? "the last week's rate" : "the month's average"})`, + }); + } if (used >= TRAFFIC_WARN) { out.push({ key: `hetzner-traffic:${id}:${s.id}`, @@ -249,6 +361,32 @@ export function hetznerProblems(id: number, name: string, servers: StoredServer[ } } } + const serverName = (sid: number | null) => (sid === null ? null : (servers.find((x) => x.id === sid)?.name ?? `#${sid}`)); + for (const lb of [...(extras.loadBalancers ?? [])].sort((a, b) => a.name.localeCompare(b.name))) { + const unhealthy = lb.targets.filter((t) => t.health === "unhealthy"); + if (unhealthy.length === 0) continue; + const names = [...new Set(unhealthy.map((t) => serverName(t.serverId) ?? t.label ?? "a target"))]; + out.push({ + key: `hetzner-lb:${id}:${lb.id}`, + serverId: 0, + severity: unhealthy.length === lb.targets.length ? "critical" : "warning", + message: `${name}: load balancer ${lb.name} has ${unhealthy.length} of ${plural(lb.targets.length, "target")} unhealthy (${names.join(", ")})${unhealthy.length === lb.targets.length ? " — it has nothing healthy to send to" : ""}`, + }); + } + for (const c of [...(extras.certificates ?? [])].sort((a, b) => a.name.localeCompare(b.name))) { + if (c.usedBy === 0) continue; // one nothing uses ending is no news + const label = `certificate ${c.name}${c.domains.length > 0 ? ` (${c.domains.slice(0, 3).join(", ")}${c.domains.length > 3 ? ", …" : ""})` : ""}`; + const left = c.notValidAfter === null ? null : (Date.parse(c.notValidAfter) - nowMs) / DAY; + if (c.issuance === "failed" || c.renewal === "failed") { + out.push({ key: `hetzner-cert:${id}:${c.id}`, serverId: 0, severity: left !== null && left <= CERT_CRITICAL_DAYS ? "critical" : "warning", message: `${name}: ${label} could not be ${c.issuance === "failed" ? "issued" : "renewed"} by Hetzner${c.error ? ` — ${c.error}` : ""}${left !== null && left > 0 ? ` (it is valid for ${plural(Math.floor(left), "more day")})` : ""}` }); + } else if (left !== null && left <= CERT_WARN_DAYS) { + out.push({ key: `hetzner-cert:${id}:${c.id}`, serverId: 0, severity: left <= CERT_CRITICAL_DAYS ? "critical" : "warning", message: `${name}: ${label} ${left <= 0 ? `ended ${ago(-left * DAY)} ago` : `ends in ${plural(Math.ceil(left), "day")}`}${c.type === "managed" ? " — Hetzner should have renewed it" : " — it was uploaded, so it has to be renewed by hand"}` }); + } + } + for (const f of [...(extras.floatingIps ?? [])].sort((a, b) => a.ip.localeCompare(b.ip))) { + if (f.serverId !== null) continue; + out.push({ key: `hetzner-fip:${id}:${f.id}`, serverId: 0, severity: "warning", message: `${name}: floating IP ${f.ip}${f.name ? ` (${f.name})` : ""} points at no server — it is billed all the same` }); + } return out; } diff --git a/server/src/services/maintenance.ts b/server/src/services/maintenance.ts index c27e251..d744fcb 100644 --- a/server/src/services/maintenance.ts +++ b/server/src/services/maintenance.ts @@ -39,10 +39,12 @@ export function subjectOfConditionKey(key: string): string | null { if (m) return `integration:${m[1]}`; m = /^speedtest-(?:slow|failing):(\d+)/.exec(key); if (m) return `integration:${m[1]}`; - m = /^hetzner-(?:off|stuck|rescue|traffic|backup):(\d+):/.exec(key); + m = /^hetzner-(?:off|stuck|rescue|traffic|forecast|backup|lb|cert|fip):(\d+):/.exec(key); if (m) return `integration:${m[1]}`; m = /^fragnet-(?:disk|memory|backup):(\d+):/.exec(key); if (m) return `integration:${m[1]}`; + m = /^(?:sonarr|radarr|prowlarr)-(?:health|queue|disk):(\d+)/.exec(key); + if (m) return `integration:${m[1]}`; m = /^netbox-(?:workers):(\d+)/.exec(key); if (m) return `integration:${m[1]}`; m = /^n8n-(?:failed):(\d+)/.exec(key); diff --git a/server/src/services/metrics.ts b/server/src/services/metrics.ts index 553f856..3f64f7c 100644 --- a/server/src/services/metrics.ts +++ b/server/src/services/metrics.ts @@ -3,9 +3,9 @@ * severity, integrations, maintenance, things that expire. It reads what the app already knows — nothing here calls out to a server or an * integration on its own, so a scrape every fifteen seconds costs a few database reads (the alerts are the app's own minute-old result). */ -import { eq } from "drizzle-orm"; +import { eq, inArray } from "drizzle-orm"; import { db } from "../db/client.js"; -import { assets, endpointChecks, heartbeats, integrations, maintenanceWindows, secrets, servers, upsState, jellyfinState, authentikState, immichState, paperlessState, nextcloudState, netboxState, n8nState, dockhandVulnerabilities, hetznerState, fragnetState } from "../db/schema.js"; +import { assets, endpointChecks, heartbeats, integrations, maintenanceWindows, secrets, servers, upsState, jellyfinState, authentikState, immichState, paperlessState, nextcloudState, netboxState, n8nState, dockhandVulnerabilities, hetznerState, fragnetState, arrState } from "../db/schema.js"; import { isUpsFresh, upsSyncStatuses } from "./upsSync.js"; import { levelStatuses } from "./serviceLevels.js"; import { backupState, listAll as listDuplicati } from "./duplicati.js"; @@ -13,7 +13,9 @@ import { isJellyfinFresh, jellyfinSyncStatuses, streamsOf } from "./jellyfinSync import { isNextcloudFresh, nextcloudSyncStatuses } from "./nextcloudSync.js"; import { dockerVulnSyncStatuses, isDockerVulnFresh } from "./dockerVulnSync.js"; import { isSpeedtestFresh, recentResults as recentSpeedtestResults, speedtestSyncStatuses } from "./speedtestSync.js"; -import { costOf as hetznerCostOf, hetznerSyncStatuses, isHetznerFresh, serversOf as hetznerServersOf } from "./hetznerSync.js"; +import { costOf as hetznerCostOf, hetznerSyncStatuses, isHetznerFresh, serversOf as hetznerServersOf, loadBalancersOf as hetznerLoadBalancersOf, certificatesOf as hetznerCertificatesOf, trafficForecast as hetznerTrafficForecast } from "./hetznerSync.js"; +import { ARR_KINDS } from "../integrations/arr/adapter.js"; +import { arrSyncStatuses, distinctDisks as arrDisks, isArrFresh, stuckItems as arrStuck, storedOf as arrStoredOf } from "./arrSync.js"; import { fragnetSyncStatuses, isFragnetFresh, newestBackup as fragnetNewestBackup, serversOf as fragnetServersOf } from "./fragnetSync.js"; import { isNetBoxFresh, netboxSyncStatuses } from "./netboxSync.js"; import { isN8nFresh, n8nSyncStatuses, workflowsOf as n8nWorkflowsOf } from "./n8nSync.js"; @@ -101,6 +103,25 @@ async function addSpeedtestMetrics(out: Exposition, now: Date) { } } +/** Each Sonarr, Radarr and Prowlarr, for /metrics: how many health findings it has, its queue and how much of it is stuck, the missing items and the free space of each disk. Only while the reading is recent. */ +async function addArrMetrics(out: Exposition, now: Date) { + const statuses = await arrSyncStatuses(); + const rows = new Map((await db.select({ id: integrations.id, name: integrations.name, type: integrations.type, enabled: integrations.enabled }).from(integrations).where(inArray(integrations.type, ARR_KINDS))).map((r) => [r.id, r])); + for (const s of await db.select().from(arrState)) { + const row = rows.get(s.integrationId); + if (!row || !row.enabled || !isArrFresh(statuses[s.integrationId], now.getTime())) continue; + const state = arrStoredOf(s); + const labels = { app: row.type, name: row.name }; + out.add("homelab_arr_health_issues", "gauge", "How many warnings or errors Sonarr, Radarr or Prowlarr reports about itself.", state.health.filter((h) => h.type === "warning" || h.type === "error").length, labels); + if (state.queue) { + out.add("homelab_arr_queue_items", "gauge", "How many downloads are in the queue of Sonarr or Radarr.", state.queue.total, labels); + out.add("homelab_arr_queue_stuck_items", "gauge", "How many of the queue's downloads are stuck (judged wrong, failed or blocked for two hours or more).", arrStuck(state.queue, now.getTime()).length, labels); + } + if (state.missing !== null) out.add("homelab_arr_wanted_missing", "gauge", "How many wanted items Sonarr or Radarr has no file for.", state.missing, labels); + for (const d of arrDisks(state.disks)) out.add("homelab_arr_disk_free_bytes", "gauge", "Free space of a disk Sonarr, Radarr or Prowlarr uses, in bytes.", d.free, { ...labels, path: d.path }); + } +} + /** Each Fragnet game server, for /metrics: whether it is running, its disk and memory against their limits and when it was last backed up. Only while the reading is recent. */ async function addFragnetMetrics(out: Exposition, now: Date) { const statuses = await fragnetSyncStatuses(); @@ -136,6 +157,16 @@ async function addHetznerMetrics(out: Exposition, now: Date) { if (server.outgoingTraffic !== null) out.add("homelab_hetzner_traffic_outgoing_bytes", "gauge", "Outgoing traffic of a Hetzner Cloud server this month, in bytes.", server.outgoingTraffic, labels); if (server.includedTraffic !== null) out.add("homelab_hetzner_traffic_included_bytes", "gauge", "The outgoing traffic a Hetzner Cloud server includes per month, in bytes.", server.includedTraffic, labels); } + for (const server of hetznerServersOf(s)) { + const forecast = hetznerTrafficForecast(server, now.getTime()); + if (forecast) out.add("homelab_hetzner_traffic_forecast_bytes", "gauge", "What a Hetzner Cloud server's outgoing traffic is forecast to come to by the end of the month, in bytes.", forecast.projectedMonth, { project: row.name, server: server.name }); + } + for (const lb of hetznerLoadBalancersOf(s) ?? []) { + out.add("homelab_hetzner_load_balancer_unhealthy_targets", "gauge", "How many targets of a Hetzner Cloud load balancer are unhealthy.", lb.targets.filter((t) => t.health === "unhealthy").length, { project: row.name, load_balancer: lb.name }); + } + for (const c of hetznerCertificatesOf(s) ?? []) { + if (c.notValidAfter) out.add("homelab_hetzner_certificate_expiry_timestamp_seconds", "gauge", "When a Hetzner Cloud certificate ends, in seconds since 1970.", Date.parse(c.notValidAfter) / 1000, { project: row.name, certificate: c.name }); + } const cost = hetznerCostOf(s); if (cost) out.add("homelab_hetzner_monthly_cost", "gauge", "Estimated monthly cost of a Hetzner Cloud project at list prices, including VAT, in the project's currency.", cost.total, { project: row.name, currency: cost.currency }); } @@ -466,6 +497,7 @@ export async function buildMetrics(now: Date = new Date()): Promise { await addHetznerMetrics(out, now); await addSpeedtestMetrics(out, now); await addFragnetMetrics(out, now); + await addArrMetrics(out, now); await addHeartbeatMetrics(out, now); return out.toString(); } diff --git a/server/test/arr.test.ts b/server/test/arr.test.ts new file mode 100644 index 0000000..44ca12b --- /dev/null +++ b/server/test/arr.test.ts @@ -0,0 +1,365 @@ +/** + * Sonarr, Radarr and Prowlarr: reading what their API says (the same one for all three), what is stored, what is wrong (their own health findings, stuck downloads, a disk nearly full), the + * health pass, the alerts, the page's data and /metrics. + * + * Run with: npm test --workspace server + */ +import { test, describe, before, after } from "node:test"; +import assert from "node:assert/strict"; +import { createServer as createHttpServer, type Server } from "node:http"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { AddressInfo } from "node:net"; + +const dir = mkdtempSync(join(tmpdir(), "hm-arr-")); +process.env.DATABASE_PATH = join(dir, "test.sqlite"); +process.env.SESSION_DIR = join(dir, "sessions"); +process.env.CREDENTIALS_ENCRYPTION_KEY = "ab".repeat(32); +process.env.HEALTH_STARTUP_GRACE_MS = "0"; + +const express = (await import("express")).default; +const { db } = await import("../src/db/client.js"); +const { users, integrations, arrState } = await import("../src/db/schema.js"); +const { runMigrations } = await import("../src/db/migrate.js"); +const adapter = await import("../src/integrations/arr/adapter.js"); +const arr = await import("../src/services/arrSync.js"); +const { evaluateHealth, collectSnapshot } = await import("../src/services/healthMonitor.js"); +const { subjectOfConditionKey } = await import("../src/services/maintenance.js"); +const { getAlerts, invalidateAlertsCache } = await import("../src/services/alerts.js"); +const { arrRouter } = await import("../src/routes/arr.js"); +const { buildMetrics } = await import("../src/services/metrics.js"); +const { setInternalFlag } = await import("../src/services/settingsStore.js"); +const { eq } = await import("drizzle-orm"); + +await runMigrations(); + +const MIN = 60_000; +const HOUR = 60 * MIN; +const GB = 1024 ** 3; +const iso = (ms: number) => new Date(ms).toISOString(); + +type Item = import("../src/integrations/arr/adapter.js").ArrQueueItem; +type Read = import("../src/integrations/arr/adapter.js").ArrRead; + +const item = (extra: Partial = {}): Item => ({ id: 1, title: "Show S01E01", status: "downloading", tracked: "ok", state: "downloading", messages: [], size: 1000, sizeLeft: 500, added: iso(Date.now() - 30 * MIN), etaAt: null, protocol: "torrent", client: "qBittorrent", indexer: "Tracker", ...extra }); +const read = (extra: Partial = {}): Read => ({ version: "4.0.9", health: [], queue: { total: 0, items: [] }, disks: [{ path: "/tv", label: null, free: 500 * GB, total: 1000 * GB }], missing: 3, indexers: null, ...extra }); + +// What the applications send. +const apiItem = (id: number, extra: Record = {}) => ({ id, title: `Show S01E0${id}`, status: "downloading", trackedDownloadStatus: "ok", trackedDownloadState: "downloading", statusMessages: [], size: 1000, sizeleft: 400, added: "2026-06-01T10:00:00Z", estimatedCompletionTime: "2026-06-01T12:00:00Z", protocol: "torrent", downloadClient: "qBittorrent", indexer: "Tracker", ...extra }); + +describe("what the *arr API says", () => { + test("health: what each check found, with its type; an entry with no message is skipped", () => { + const h = adapter.parseHealth([{ source: "DownloadClientCheck", type: "error", message: "No download client is available", wikiUrl: "x" }, { source: "UpdateCheck", type: "notice", message: "New update is available" }, { source: "Empty", type: "warning" }, "junk"]); + assert.deepEqual(h.map((x) => [x.source, x.type, x.message]), [["DownloadClientCheck", "error", "No download client is available"], ["UpdateCheck", "notice", "New update is available"]]); + assert.deepEqual(adapter.parseHealth({ message: "no" }), []); + }); + + test("a queue item: its status and how the download is judged, what it says is wrong (the error first), size, times, client and indexer", () => { + const q = adapter.parseQueueItem(apiItem(4, { status: "warning", trackedDownloadStatus: "warning", trackedDownloadState: "importBlocked", errorMessage: "Import failed", statusMessages: [{ title: "Show.S01E04.mkv", messages: ["Not an upgrade", "Not an upgrade"] }, { title: "No files found", messages: [] }] }))!; + assert.deepEqual([q.id, q.status, q.tracked, q.state, q.size, q.sizeLeft, q.client, q.indexer, q.added, q.etaAt], [4, "warning", "warning", "importBlocked", 1000, 400, "qBittorrent", "Tracker", "2026-06-01T10:00:00.000Z", "2026-06-01T12:00:00.000Z"]); + assert.deepEqual(q.messages, ["Import failed", "Show.S01E04.mkv: Not an upgrade", "No files found"]); + }); + + test("an item without an id is skipped; a page is read with the total the application says", () => { + assert.equal(adapter.parseQueueItem({ title: "x" }), null); + const q = adapter.parseQueue({ page: 1, pageSize: 100, totalRecords: 250, records: [apiItem(1), { title: "no id" }, apiItem(2)] }); + assert.deepEqual([q.total, q.items.map((i) => i.id)], [250, [1, 2]]); + assert.deepEqual(adapter.parseQueue(null), { total: 0, items: [] }); + }); + + test("disks: where, how much is free and how big", () => { + const d = adapter.parseDisks([{ path: "/tv", label: "TV", freeSpace: 10, totalSpace: 100 }, { path: "/x" }, "junk"]); + assert.deepEqual(d, [{ path: "/tv", label: "TV", free: 10, total: 100 }]); + }); + + test("Prowlarr's indexers: the ones it has switched off after failures say until when", () => { + const list = adapter.parseIndexers([{ id: 2, name: "B", enable: true, protocol: "torrent" }, { id: 1, name: "A", enable: false, protocol: "usenet" }, { id: 3, name: "C" }], [{ indexerId: 2, disabledTill: "2026-06-02T00:00:00Z", mostRecentFailure: "2026-06-01T00:00:00Z" }]); + assert.deepEqual(list.map((i) => [i.name, i.enabled, i.disabledTill]), [["A", false, null], ["B", true, "2026-06-02T00:00:00.000Z"], ["C", true, null]]); + }); + + describe("the adapter against applications that answer", () => { + let fake: Server; + let url = ""; + let keyOk = true; + let queueStatus = 200; + let appName = "Sonarr"; + const seen: { method: string | undefined; path: string; key: string | string[] | undefined }[] = []; + before(async () => { + fake = createHttpServer((req, res) => { + const u = new URL(req.url ?? "", "http://x"); + seen.push({ method: req.method, path: u.pathname + u.search, key: req.headers["x-api-key"] }); + const send = (code: number, body: unknown) => { + res.writeHead(code, { "content-type": "application/json" }); + res.end(JSON.stringify(body)); + }; + if (!keyOk) return send(401, { error: "Unauthorized" }); + const p = u.pathname.replace(/^\/api\/v[13]/, ""); + if (p === "/system/status") return send(200, { appName, version: "4.0.9" }); + if (p === "/health") return send(200, [{ source: "IndexerStatusCheck", type: "warning", message: "Indexers unavailable due to failures: A" }]); + if (p === "/queue") return queueStatus === 200 ? send(200, { totalRecords: 1, records: [apiItem(1)] }) : send(queueStatus, {}); + if (p === "/diskspace") return send(200, [{ path: "/tv", freeSpace: 100, totalSpace: 1000 }]); + if (p === "/wanted/missing") return send(200, { totalRecords: 7, records: [] }); + if (p === "/indexer") return send(200, [{ id: 1, name: "A", enable: true, protocol: "torrent" }]); + if (p === "/indexerstatus") return send(200, [{ indexerId: 1, disabledTill: "2026-06-02T00:00:00Z" }]); + send(404, {}); + }); + await new Promise((resolve) => fake.listen(0, "127.0.0.1", resolve)); + url = `http://127.0.0.1:${(fake.address() as AddressInfo).port}`; + }); + after(() => fake.close()); + + test("Sonarr: version, health, the queue (asked with its own include), the disks and the missing — with the key in X-Api-Key, and only ever GET", async () => { + seen.length = 0; + const r = await adapter.createArrAdapter("sonarr", { url, apiKey: "k1" }).read(); + assert.deepEqual([r.version, r.health.length, r.queue?.total, r.disks?.length, r.missing, r.indexers], ["4.0.9", 1, 1, 1, 7, null]); + assert.ok(seen.every((s) => s.method === "GET" && s.key === "k1")); + assert.ok(seen.some((s) => s.path.startsWith("/api/v3/queue?page=1&pageSize=100&includeUnknownSeriesItems=true"))); + }); + + test("Radarr asks for movies; Prowlarr is under v1, has no queue, and gives its indexers", async () => { + seen.length = 0; + await adapter.createArrAdapter("radarr", { url, apiKey: "k" }).read(); + assert.ok(seen.some((s) => s.path.includes("includeUnknownMovieItems=true"))); + seen.length = 0; + const r = await adapter.createArrAdapter("prowlarr", { url, apiKey: "k" }).read(); + assert.deepEqual([r.queue, r.missing, r.indexers?.[0].name, r.indexers?.[0].disabledTill], [null, null, "A", "2026-06-02T00:00:00.000Z"]); + assert.ok(seen.every((s) => s.path.startsWith("/api/v1/"))); + assert.ok(!seen.some((s) => s.path.includes("/queue"))); + }); + + test("a part that cannot be read is null, not empty; the status and the health are what must work", async () => { + queueStatus = 500; + const r = await adapter.createArrAdapter("sonarr", { url, apiKey: "k" }).read(); + assert.deepEqual([r.queue, r.disks?.length], [null, 1]); + queueStatus = 200; + }); + + test("a key that is refused, an address that is not the application, and the wrong kind are said", async () => { + keyOk = false; + const ping = await adapter.createArrAdapter("sonarr", { url, apiKey: "bad" }).ping(); + assert.equal(ping.ok, false); + assert.match(ping.error ?? "", /Sonarr did not accept the API key \(HTTP 401\)/); + keyOk = true; + appName = "Radarr"; + assert.match((await adapter.createArrAdapter("sonarr", { url, apiKey: "k" }).ping()).error ?? "", /That is Radarr, not Sonarr/); + appName = "Sonarr"; + assert.equal((await adapter.createArrAdapter("sonarr", { url, apiKey: "k" }).ping()).ok, true); + assert.equal((await adapter.createArrAdapter("sonarr", { url: "http://127.0.0.1:1", apiKey: "k" }).ping()).ok, false); + await assert.rejects(() => adapter.createArrAdapter("sonarr", { url: `${url}/nowhere`, apiKey: "k" }).read(), /no API at this address/); + }); + }); +}); + +describe("what is wrong", () => { + const NOW = Date.parse("2026-06-10T12:00:00Z"); + const state = (extra: Partial = {}) => ({ version: "4", health: [], queue: { total: 0, items: [] }, disks: null, missing: 0, indexers: null, updatedAt: iso(NOW), ...extra }); + const keys = (list: ReturnType) => list.map((p) => `${p.key}=${p.severity}`); + const old = (extra: Partial = {}) => item({ added: iso(NOW - 3 * HOUR), ...extra }); + + test("an application that is well says nothing", () => { + assert.deepEqual(arr.arrProblems("sonarr", 1, "TV", state({ queue: { total: 1, items: [item({ added: iso(NOW - 10 * MIN) })] }, disks: [{ path: "/tv", label: null, free: 500 * GB, total: 1000 * GB }] }), NOW), []); + }); + + describe("what it says itself", () => { + test("a warning or an error is raised, a notice is not; the message says who says it", () => { + const p = arr.arrProblems("sonarr", 1, "TV", state({ health: [{ source: "DownloadClientCheck", type: "error", message: "No download client is available" }, { source: "UpdateCheck", type: "notice", message: "New update available" }, { source: "RootFolderCheck", type: "warning", message: "Missing root folder: /tv " }] }), NOW); + assert.equal(p.length, 2); + assert.match(p[0].message, /^TV: Sonarr says no download client is available$/); + assert.match(p[1].message, /Sonarr says missing root folder: \/tv$/); + assert.ok(p.every((x) => x.severity === "warning" && x.key.startsWith("sonarr-health:1:"))); + }); + test("a finding keeps its key when only its numbers change, and has another when its words do", () => { + const key = (m: string) => arr.arrProblems("prowlarr", 3, "P", state({ health: [{ source: "IndexerStatusCheck", type: "warning", message: m }] }), NOW)[0].key; + assert.equal(key("3 indexers are unavailable"), key("4 indexers are unavailable")); + assert.notEqual(key("3 indexers are unavailable"), key("Download client missing")); + assert.match(key("x"), /^prowlarr-health:3:indexerstatuscheck-/); + }); + }); + + describe("downloads that are stuck", () => { + test("judged wrong for two hours is stuck; younger is left alone; one judged fine is not stuck however old", () => { + assert.equal(arr.isStuck(old({ tracked: "warning" }), NOW), true); + assert.equal(arr.isStuck(item({ tracked: "warning", added: iso(NOW - 30 * MIN) }), NOW), false); + assert.equal(arr.isStuck(old({ tracked: "ok", state: "downloading" }), NOW), false); + }); + test("failed, failing and blocked from importing count, whatever the tracked status says", () => { + for (const state of ["failed", "failedPending", "importBlocked"]) assert.equal(arr.isStuck(old({ tracked: "ok", state }), NOW), true, state); + assert.equal(arr.isStuck(old({ tracked: null, state: null, status: "failed" }), NOW), true); + assert.equal(arr.isStuck(old({ tracked: "error", added: null }), NOW), false, "one with no time cannot be called old"); + }); + test("one alert for the lot: how many, the first three by name, the oldest's age and why", () => { + const items = [old({ id: 1, title: "A", tracked: "error", messages: ["No files found"], added: iso(NOW - 30 * HOUR) }), old({ id: 2, title: "B", tracked: "warning" }), old({ id: 3, title: "C", state: "failed" }), old({ id: 4, title: "D", tracked: "warning" }), item({ id: 5, title: "fine" })]; + const p = arr.arrProblems("radarr", 2, "Films", state({ queue: { total: 5, items } }), NOW); + assert.deepEqual(keys(p), ["radarr-queue:2=warning"]); + assert.equal(p[0].message, "Films: 4 downloads are stuck — A; B; C; and 1 more (the oldest for 30 hours) — No files found"); + assert.match(arr.arrProblems("radarr", 2, "Films", state({ queue: { total: 1, items: [items[0]] } }), NOW)[0].message, /^Films: 1 download is stuck — A \(the oldest for 30 hours\)/); + }); + test("a queue that could not be read says nothing; Prowlarr has none", () => { + assert.deepEqual(arr.arrProblems("sonarr", 1, "TV", state({ queue: null }), NOW), []); + }); + }); + + describe("disks", () => { + const disk = (path: string, free: number, total = 1000) => ({ path, label: null, free: free * GB, total: total * GB }); + test("under 10% free is a warning, under 5% critical; the message says how much", () => { + assert.deepEqual(arr.arrProblems("sonarr", 1, "TV", state({ disks: [disk("/tv", 150)] }), NOW), []); + const warn = arr.arrProblems("sonarr", 1, "TV", state({ disks: [disk("/tv", 80)] }), NOW); + assert.deepEqual(keys(warn), ["sonarr-disk:1:tv=warning"]); + assert.equal(warn[0].message, "TV: /tv has 80.0 GB free of 1000 GB (8%)"); + assert.deepEqual(keys(arr.arrProblems("sonarr", 1, "TV", state({ disks: [disk("/tv", 30)] }), NOW)), ["sonarr-disk:1:tv=critical"]); + }); + test("folders on one disk are one disk (the shortest path names it); a tiny disk is not a media disk; an unread list says nothing", () => { + const d = arr.distinctDisks([disk("/data/tv/anime", 30), disk("/data", 30), disk("/data/tv", 30), disk("/boot", 0.1, 1), disk("/movies", 600)]); + assert.deepEqual(d.map((x) => x.path), ["/data", "/movies"]); + assert.deepEqual(keys(arr.arrProblems("sonarr", 1, "TV", state({ disks: [disk("/data/tv", 30), disk("/data", 30)] }), NOW)), ["sonarr-disk:1:data=critical"]); + assert.deepEqual(arr.arrProblems("sonarr", 1, "TV", state({ disks: null }), NOW), []); + }); + }); +}); + +describe("what is stored", () => { + let id = 0; + before(async () => { + id = (await db.insert(integrations).values({ type: "sonarr", name: "TV", baseUrl: "http://sonarr", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + }); + const row = async () => (await db.select().from(arrState).where(eq(arrState.integrationId, id)))[0]; + after(async () => { + await arr.forgetArr(id); + await db.delete(integrations).where(eq(integrations.id, id)); + }); + + test("the state is replaced at each read; a part that could not be read is stored as null", async () => { + await arr.storeRead(id, read({ queue: null, disks: null }), new Date()); + let s = arr.storedOf(await row()); + assert.deepEqual([s.queue, s.disks, s.missing, s.health], [null, null, 3, []]); + await arr.storeRead(id, read({ queue: { total: 1, items: [item()] }, health: [{ source: "x", type: "warning", message: "m" }] }), new Date()); + s = arr.storedOf(await row()); + assert.deepEqual([s.queue?.total, s.health.length], [1, 1]); + }); + + test("a read that failed is said, and what was stored is left alone", async () => { + const ok = await arr.syncArr(id, new Date(), async () => read({ version: "kept" })); + assert.equal(ok.ok, true); + const failed = await arr.syncArr(id, new Date(), async () => { + throw new Error("connection refused"); + }); + assert.deepEqual([failed.ok, failed.error], [false, "connection refused"]); + assert.equal(failed.at, ok.at); + assert.equal(arr.storedOf(await row()).version, "kept"); + assert.equal(arr.isArrFresh((await arr.arrSyncStatuses())[id], Date.now()), false); + }); + + test("the kind is what the read is asked for", async () => { + const asked: string[] = []; + await arr.syncArr(id, new Date(), async (kind) => { + asked.push(kind); + return read(); + }); + assert.deepEqual(asked, ["sonarr"]); + }); +}); + +describe("the health pass, the page and /metrics", () => { + let tvId = 0; + let pId = 0; + let app: Server; + let base = ""; + const fresh = () => setInternalFlag("arrSync", JSON.stringify({ [tvId]: { at: new Date().toISOString(), ok: true, error: null }, [pId]: { at: new Date().toISOString(), ok: true, error: null } })); + const stale = () => setInternalFlag("arrSync", JSON.stringify({ [tvId]: { at: new Date(Date.now() - 30 * MIN).toISOString(), ok: true, error: null }, [pId]: { at: new Date().toISOString(), ok: true, error: null } })); + + before(async () => { + await db.insert(users).values([{ oidcSub: "viewer", name: "Vic", role: "viewer" }]); + const mk = async (type: "sonarr" | "prowlarr", name: string) => (await db.insert(integrations).values({ type, name, baseUrl: `http://${name}`, config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + tvId = await mk("sonarr", "TV"); + pId = await mk("prowlarr", "Indexers"); + const now = Date.now(); + await arr.storeRead( + tvId, + read({ + health: [{ source: "DownloadClientCheck", type: "error", message: "No download client is available" }], + queue: { total: 3, items: [item({ id: 1, tracked: "error", added: iso(now - 5 * HOUR), messages: ["No files found"] }), item({ id: 2 }), item({ id: 3, state: "importBlocked", added: iso(now - 4 * HOUR) })] }, + disks: [{ path: "/tv", label: null, free: 20 * GB, total: 1000 * GB }], + }), + new Date(), + ); + await arr.storeRead(pId, read({ queue: null, missing: null, disks: null, indexers: [{ id: 1, name: "A", enabled: true, protocol: "torrent", disabledTill: iso(now + HOUR), lastFailure: iso(now) }], health: [{ source: "IndexerStatusCheck", type: "warning", message: "Indexers unavailable due to failures: A" }] }), new Date()); + await fresh(); + const a = express(); + a.use((req, _res, next) => { + (req as unknown as { session: unknown }).session = { user: { sub: "viewer" } }; + next(); + }); + a.use("/api/arr", arrRouter); + app = await new Promise((resolve) => { + const s = a.listen(0, "127.0.0.1", () => resolve(s)); + }); + base = `http://127.0.0.1:${(app.address() as AddressInfo).port}/api/arr`; + }); + after(() => { + app.close(); + try { + rmSync(dir, { recursive: true, force: true }); + } catch { + // Windows keeps the database file locked until the process exits. + } + }); + + test("the health pass judges each from what is stored, and holds one whose last read is old", async () => { + let { snapshot, held } = await collectSnapshot(); + assert.deepEqual(snapshot.arr?.map((a) => [a.kind, a.integrationId]).sort(), [["prowlarr", pId], ["sonarr", tvId]].sort()); + const list = evaluateHealth(snapshot, { serverOfflineMinutes: 60, diskUsagePercent: 90 }, Date.now(), { skipServers: true }); + const mine = list.filter((x) => /^(sonarr|prowlarr)-/.test(x.key)); + assert.deepEqual(mine.map((x) => x.key.replace(/^([a-z]+-[a-z]+:[0-9]+).*$/, "$1")).sort(), [`prowlarr-health:${pId}`, `sonarr-disk:${tvId}`, `sonarr-health:${tvId}`, `sonarr-queue:${tvId}`].sort()); + const disk = mine.find((x) => x.key === `sonarr-disk:${tvId}:tv`)!; + assert.deepEqual([disk.severity, disk.source], ["critical", `sonarr:${tvId}`]); + for (const k of ["health", "queue", "disk"]) assert.equal(subjectOfConditionKey(`sonarr-${k}:${tvId}:x`), `integration:${tvId}`); + await stale(); + ({ snapshot, held } = await collectSnapshot()); + assert.deepEqual([snapshot.arr?.map((a) => a.integrationId), held.has(`sonarr:${tvId}`)], [[pId], true]); + await fresh(); + }); + + test("the Alerts page says where to look: the disk under Disk, the rest under Services, and the link is the media page", async () => { + invalidateAlertsCache(); + const report = await getAlerts(true); + const q = report.alerts.find((x) => x.id.endsWith(`sonarr-queue:${tvId}`))!; + const d = report.alerts.find((x) => x.id.endsWith(`sonarr-disk:${tvId}:tv`))!; + assert.deepEqual([q.category, q.source, q.link, q.target?.type, d.category], ["services", "Sonarr", "/media", "integration", "disk"]); + assert.match(q.message ?? "", /2 downloads are stuck/); + }); + + test("the page: each application with its kind, what it says, its queue (the stuck ones marked), its disks and, for Prowlarr, its indexers", async () => { + const body = (await (await fetch(base)).json()) as { apps: { id: number; kind: string; fresh: boolean; problems: { key: string }[]; state: { stuck: number[]; queue: { total: number } | null; disks: { path: string }[]; indexers: { name: string }[] | null; health: unknown[] } }[] }; + const tv = body.apps.find((a) => a.id === tvId)!; + assert.deepEqual([tv.kind, tv.fresh, tv.state.queue?.total, tv.state.stuck.sort(), tv.state.disks.map((d) => d.path), tv.state.health.length], ["sonarr", true, 3, [1, 3], ["/tv"], 1]); + assert.equal(tv.problems.length, 3); + const p = body.apps.find((a) => a.id === pId)!; + assert.deepEqual([p.kind, p.state.queue, p.state.indexers?.map((i) => i.name), p.problems.length], ["prowlarr", null, ["A"], 1]); + await stale(); + const old = (await (await fetch(base)).json()) as typeof body; + assert.deepEqual(old.apps.find((a) => a.id === tvId)!.problems, [], "an old reading says nothing is wrong"); + await fresh(); + }); + + test("/metrics has the health findings, the queue and what is stuck, the missing and each disk's free space — only while the reading is recent", async () => { + let text = await buildMetrics(new Date()); + assert.match(text, /homelab_arr_health_issues\{app="sonarr",name="TV"\} 1/); + assert.match(text, /homelab_arr_queue_items\{app="sonarr",name="TV"\} 3/); + assert.match(text, /homelab_arr_queue_stuck_items\{app="sonarr",name="TV"\} 2/); + assert.match(text, /homelab_arr_wanted_missing\{app="sonarr",name="TV"\} 3/); + assert.match(text, /homelab_arr_disk_free_bytes\{app="sonarr",name="TV",path="\/tv"\} 21474836480/); + assert.doesNotMatch(text, /homelab_arr_queue_items\{app="prowlarr"/, "Prowlarr has no queue"); + await stale(); + text = await buildMetrics(new Date()); + assert.doesNotMatch(text, /homelab_arr_[a-z_]+\{app="sonarr"/); + await fresh(); + }); + + test("taking the integration away takes what was read with it", async () => { + await arr.forgetArr(tvId); + assert.equal((await arr.arrSyncStatuses())[tvId], undefined); + await db.delete(integrations).where(eq(integrations.id, tvId)); + assert.deepEqual(await db.select().from(arrState).where(eq(arrState.integrationId, tvId)), []); + }); +}); diff --git a/server/test/hetzner.test.ts b/server/test/hetzner.test.ts index ac868c4..d93dacb 100644 --- a/server/test/hetzner.test.ts +++ b/server/test/hetzner.test.ts @@ -210,7 +210,7 @@ describe("the cost estimate", () => { primaryIps: [{ id: 1, ip: "1.1.1.1", type: "ipv4", location: "fsn1", assigned: true }, { id: 2, ip: "1.1.1.2", type: "ipv4", location: "fsn1", assigned: false }], prices: PRICES, })!; - assert.deepEqual({ ...c }, { currency: "EUR", servers: 15, backups: 2, volumes: 5, snapshots: 0.12, ips: 1, total: 23.12, unassignedIps: 1, unpriced: 0 }); + assert.deepEqual({ ...c }, { currency: "EUR", servers: 15, backups: 2, volumes: 5, snapshots: 0.12, ips: 1, loadBalancers: 0, floatingIps: 0, total: 23.12, unassignedIps: 1, unpriced: 0 }); }); test("without the price list there is no estimate; a server whose price is not known is counted as unpriced", () => { @@ -251,7 +251,8 @@ describe("what is wrong", () => { }); test("traffic: a warning from 80% of the month's quota, critical at 100%, in the units the page shows", () => { - assert.deepEqual(problems(stored({ outgoingTraffic: 15 * TB })), []); + assert.deepEqual(keys(problems(stored({ outgoingTraffic: 15 * TB }))), ["hetzner-forecast:1:1=warning"], "75% on the tenth is on course to pass it: the forecast, not yet the traffic alert"); + assert.deepEqual(problems(stored({ outgoingTraffic: 5 * TB })), []); const warn = problems(stored({ outgoingTraffic: 17 * TB })); assert.deepEqual(keys(warn), ["hetzner-traffic:1:1=warning"]); assert.match(warn[0].message, /web has sent 17\.0 TB of its 20\.0 TB traffic this month \(85%\)/); diff --git a/server/test/hetznerExtras.test.ts b/server/test/hetznerExtras.test.ts new file mode 100644 index 0000000..798f80d --- /dev/null +++ b/server/test/hetznerExtras.test.ts @@ -0,0 +1,390 @@ +/** + * Hetzner Cloud, the second round: load balancers (and the health of their targets), floating IPs, certificates (and when they end), their share of the cost, and the traffic forecast + * ("at this rate the server passes its quota on the 24th"). What the API says, what is stored, what is wrong, the page's data, the health pass and /metrics. + * + * Run with: npm test --workspace server + */ +import { test, describe, before, after } from "node:test"; +import assert from "node:assert/strict"; +import { createServer as createHttpServer, type Server } from "node:http"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { AddressInfo } from "node:net"; + +const dir = mkdtempSync(join(tmpdir(), "hm-hetzner2-")); +process.env.DATABASE_PATH = join(dir, "test.sqlite"); +process.env.SESSION_DIR = join(dir, "sessions"); +process.env.CREDENTIALS_ENCRYPTION_KEY = "ab".repeat(32); +process.env.HEALTH_STARTUP_GRACE_MS = "0"; + +const express = (await import("express")).default; +const { db } = await import("../src/db/client.js"); +const { users, integrations } = await import("../src/db/schema.js"); +const { runMigrations } = await import("../src/db/migrate.js"); +const adapter = await import("../src/integrations/hetzner/adapter.js"); +const hz = await import("../src/services/hetznerSync.js"); +const { evaluateHealth, collectSnapshot } = await import("../src/services/healthMonitor.js"); +const { subjectOfConditionKey } = await import("../src/services/maintenance.js"); +const { getAlerts, invalidateAlertsCache } = await import("../src/services/alerts.js"); +const { hetznerRouter } = await import("../src/routes/hetzner.js"); +const { buildMetrics } = await import("../src/services/metrics.js"); +const { setInternalFlag } = await import("../src/services/settingsStore.js"); + +await runMigrations(); + +const MIN = 60_000; +const HOUR = 60 * MIN; +const DAY = 24 * HOUR; +const TB = 1024 ** 4; +const iso = (ms: number) => new Date(ms).toISOString(); + +type Server_ = import("../src/integrations/hetzner/adapter.js").HetznerServer; +type Read = import("../src/integrations/hetzner/adapter.js").HetznerRead; +type Lb = import("../src/integrations/hetzner/adapter.js").HetznerLoadBalancer; +type Cert = import("../src/integrations/hetzner/adapter.js").HetznerCertificate; +type Fip = import("../src/integrations/hetzner/adapter.js").HetznerFloatingIp; + +const server = (extra: Partial = {}): Server_ => ({ id: 1, name: "web", status: "running", created: iso(Date.now() - 30 * DAY), type: "cx22", cores: 2, memoryGb: 4, diskGb: 40, location: "fsn1", city: "Falkenstein", os: "Ubuntu 24.04", ipv4: "203.0.113.5", ipv6: null, privateIps: [], locked: false, rescueEnabled: false, backupWindow: null, includedTraffic: 20 * TB, outgoingTraffic: 1 * TB, ingoingTraffic: 2 * TB, monthlyPrice: 4, ...extra }); +const lb = (extra: Partial = {}): Lb => ({ id: 10, name: "front", type: "lb11", location: "fsn1", ipv4: "203.0.113.50", ipv6: null, algorithm: "round_robin", services: 1, targets: [{ kind: "server", serverId: 1, label: null, health: "healthy" }], includedTraffic: 20 * TB, outgoingTraffic: 0, monthlyPrice: 6, ...extra }); +const cert = (extra: Partial = {}): Cert => ({ id: 20, name: "site", type: "managed", domains: ["example.se", "www.example.se"], notValidAfter: iso(Date.now() + 60 * DAY), issuance: "completed", renewal: "completed", error: null, usedBy: 1, ...extra }); +const fip = (extra: Partial = {}): Fip => ({ id: 30, name: "vip", ip: "203.0.113.60", type: "ipv4", serverId: 1, location: "fsn1", description: null, ...extra }); +const PRICES = { currency: "EUR", imagePerGb: 0.012, volumePerGb: 0.05, backupPercent: 20, primaryIps: [], floatingIps: [{ type: "ipv4", location: "fsn1", monthly: 3.5 }] }; + +describe("what Hetzner says of load balancers, floating IPs and certificates", () => { + test("load balancers: type and place (and its price there), address, services — and each target's health: unhealthy as soon as one port is", () => { + const [l] = adapter.parseLoadBalancers({ + load_balancers: [ + { + id: 10, + name: "front", + public_net: { ipv4: { ip: "203.0.113.50" }, ipv6: { ip: "2001:db8::1" } }, + load_balancer_type: { name: "lb11", prices: [{ location: "nbg1", price_monthly: { gross: "5.0" } }, { location: "fsn1", price_monthly: { gross: "6.4" } }] }, + location: { name: "fsn1" }, + algorithm: { type: "round_robin" }, + services: [{ listen_port: 80 }, { listen_port: 443 }], + included_traffic: 21_990_232_555_520, + outgoing_traffic: 1000, + targets: [ + { type: "server", server: { id: 1 }, health_status: [{ listen_port: 80, status: "healthy" }, { listen_port: 443, status: "healthy" }] }, + { type: "server", server: { id: 2 }, health_status: [{ listen_port: 80, status: "healthy" }, { listen_port: 443, status: "unhealthy" }] }, + { type: "server", server: { id: 3 }, health_status: [] }, + { type: "ip", ip: { ip: "198.51.100.7" }, health_status: [{ listen_port: 80, status: "unhealthy" }] }, + ], + }, + ], + }); + assert.deepEqual([l.name, l.type, l.location, l.ipv4, l.algorithm, l.services, l.monthlyPrice, l.includedTraffic], ["front", "lb11", "fsn1", "203.0.113.50", "round_robin", 2, 6.4, 21_990_232_555_520]); + assert.deepEqual(l.targets.map((t) => [t.kind, t.serverId ?? t.label, t.health]), [["server", 1, "healthy"], ["server", 2, "unhealthy"], ["server", 3, "unknown"], ["ip", "198.51.100.7", "unhealthy"]]); + }); + + test("a label selector is the servers it found (each with its own health), or itself when it found none", () => { + const [l] = adapter.parseLoadBalancers({ + load_balancers: [ + { + id: 1, + name: "x", + targets: [ + { type: "label_selector", label_selector: { selector: "env=prod" }, targets: [{ type: "server", server: { id: 4 }, health_status: [{ status: "healthy" }] }, { type: "server", server: { id: 5 }, health_status: [{ status: "unhealthy" }] }] }, + { type: "label_selector", label_selector: { selector: "env=none" }, targets: [] }, + ], + }, + ], + }); + assert.deepEqual(l.targets.map((t) => [t.serverId, t.label, t.health]), [[4, "env=prod", "healthy"], [5, "env=prod", "unhealthy"], [null, "env=none", "unknown"]]); + }); + + test("without an id or a name, or with nothing to read, a load balancer is skipped and the fields are null", () => { + assert.deepEqual(adapter.parseLoadBalancers({ load_balancers: [{ id: 1 }, { name: "x" }, "junk"] }), []); + const [bare] = adapter.parseLoadBalancers({ load_balancers: [{ id: 2, name: "bare" }] }); + assert.deepEqual([bare.type, bare.ipv4, bare.monthlyPrice, bare.targets, bare.services], [null, null, null, [], 0]); + assert.deepEqual(adapter.parseLoadBalancers(null), []); + }); + + test("floating IPs: the address, what it points at (nothing is none) and where it lives", () => { + const list = adapter.parseFloatingIps({ floating_ips: [{ id: 1, name: "vip", ip: "203.0.113.60", type: "ipv4", server: 5, home_location: { name: "fsn1" }, description: "web" }, { id: 2, ip: "203.0.113.61", type: "ipv4", server: null }, { id: 3, ip: "x", type: "weird" }, { id: 4 }] }); + assert.deepEqual(list.map((f) => [f.ip, f.serverId, f.location, f.name]), [["203.0.113.60", 5, "fsn1", "vip"], ["203.0.113.61", null, null, null]]); + }); + + test("certificates: the domains, when it ends, how its issuing and renewal went, and how many things use it", () => { + const list = adapter.parseCertificates({ + certificates: [ + { id: 1, name: "site", type: "managed", domain_names: ["example.se", "www.example.se"], not_valid_after: "2026-09-01T10:00:00+00:00", status: { issuance: "completed", renewal: "scheduled" }, used_by: [{ id: 10, type: "load_balancer" }] }, + { id: 2, name: "new", type: "managed", domain_names: ["a.se"], not_valid_after: null, status: { issuance: "failed", error: { code: "x", message: "DNS did not answer" } }, used_by: [] }, + { id: 3 }, + ], + }); + assert.deepEqual(list.map((c) => [c.name, c.type, c.domains.length, c.notValidAfter, c.issuance, c.error, c.usedBy]), [["site", "managed", 2, "2026-09-01T10:00:00.000Z", "completed", null, 1], ["new", "managed", 1, null, "failed", "DNS did not answer", 0]]); + }); + + test("the price list: a floating IP's price for each kind and place — or the one price an older list has", () => { + const p = adapter.parsePrices({ pricing: { currency: "EUR", floating_ips: [{ type: "ipv4", prices: [{ location: "fsn1", price_monthly: { gross: "3.5700" } }] }] } })!; + assert.deepEqual(p.floatingIps, [{ type: "ipv4", location: "fsn1", monthly: 3.57 }]); + const old = adapter.parsePrices({ pricing: { currency: "EUR", floating_ip: { price_monthly: { gross: "3.1" } } } })!; + assert.deepEqual(old.floatingIps.map((f) => [f.type, f.location, f.monthly]), [["ipv4", "*", 3.1], ["ipv6", "*", 3.1]]); + }); + + describe("the adapter against a Hetzner that answers", () => { + let fake: Server; + let url = ""; + let lbStatus = 200; + before(async () => { + fake = createHttpServer((req, res) => { + const u = new URL(req.url ?? "", "http://x"); + const send = (code: number, body: unknown) => { + res.writeHead(code, { "content-type": "application/json" }); + res.end(JSON.stringify(body)); + }; + const page = { meta: { pagination: { page: 1, next_page: null } } }; + if (u.pathname === "/v1/servers") return send(200, { servers: [{ id: 1, name: "web" }], ...page }); + if (u.pathname === "/v1/load_balancers") return lbStatus === 200 ? send(200, { load_balancers: [{ id: 10, name: "front", targets: [] }], ...page }) : send(lbStatus, {}); + if (u.pathname === "/v1/floating_ips") return send(200, { floating_ips: [{ id: 30, ip: "203.0.113.60", type: "ipv4", server: null }], ...page }); + if (u.pathname === "/v1/certificates") return send(200, { certificates: [{ id: 20, name: "site", used_by: [] }], ...page }); + if (u.pathname === "/v1/pricing") return send(200, { pricing: { currency: "EUR" } }); + send(200, { volumes: [], images: [], primary_ips: [], ...page }); + }); + await new Promise((resolve) => fake.listen(0, "127.0.0.1", resolve)); + url = `http://127.0.0.1:${(fake.address() as AddressInfo).port}/v1`; + }); + after(() => fake.close()); + + test("they are read with the rest; a list that cannot be asked is unknown (null), not empty", async () => { + const r = await adapter.createHetznerAdapter({ token: "t", apiUrl: url }).read(); + assert.deepEqual([r.loadBalancers?.length, r.floatingIps?.[0].serverId, r.certificates?.[0].name], [1, null, "site"]); + lbStatus = 500; + const r2 = await adapter.createHetznerAdapter({ token: "t", apiUrl: url }).read(); + assert.deepEqual([r2.loadBalancers, r2.floatingIps?.length, r2.servers.length], [null, 1, 1]); + lbStatus = 200; + }); + }); +}); + +describe("the cost with load balancers and floating IPs", () => { + test("a load balancer is its type's price, a floating IP its kind's and place's; one without a price is counted as unpriced", () => { + const base = { servers: [server({ monthlyPrice: 10 })], volumes: [], images: [], primaryIps: [], prices: PRICES }; + const c = hz.estimateCost({ ...base, loadBalancers: [lb({ monthlyPrice: 6 }), lb({ id: 11, monthlyPrice: null })], floatingIps: [fip(), fip({ id: 31, location: "hel1" })] })!; + assert.deepEqual([c.loadBalancers, c.floatingIps, c.total, c.unpriced], [6, 3.5, 19.5, 2]); + }); + test("a list that could not be read adds nothing", () => { + const c = hz.estimateCost({ servers: [server({ monthlyPrice: 10 })], volumes: [], images: [], primaryIps: [], prices: PRICES, loadBalancers: null, floatingIps: null })!; + assert.deepEqual([c.loadBalancers, c.floatingIps, c.total], [0, 0, 10]); + }); + test("an older price list's one price counts for every place", () => { + const c = hz.estimateCost({ servers: [], volumes: [], images: [], primaryIps: [], prices: { ...PRICES, floatingIps: [{ type: "ipv4", location: "*", monthly: 3 }] }, floatingIps: [fip({ location: "ash" })] })!; + assert.equal(c.floatingIps, 3); + }); +}); + +describe("the traffic history", () => { + const t0 = new Date("2026-06-10T00:00:00Z"); + test("one sample about every six hours, not more often; two weeks are kept", () => { + let h = hz.carryTraffic(1 * TB, [], t0); + h = hz.carryTraffic(1.1 * TB, h, new Date(t0.getTime() + HOUR)); + assert.equal(h.length, 1, "a read an hour later adds nothing"); + h = hz.carryTraffic(1.2 * TB, h, new Date(t0.getTime() + 7 * HOUR)); + assert.equal(h.length, 2); + h = hz.carryTraffic(5 * TB, h, new Date(t0.getTime() + 15 * DAY)); + assert.deepEqual(h.map((x) => x.bytes), [5 * TB], "what is over two weeks old is dropped"); + }); + test("a counter that goes down is a new month: the history starts over", () => { + let h = hz.carryTraffic(18 * TB, [], t0); + h = hz.carryTraffic(0.2 * TB, h, new Date(t0.getTime() + 7 * HOUR)); + assert.deepEqual(h.map((x) => x.bytes), [0.2 * TB]); + }); + test("a server that said nothing of its traffic keeps what it had", () => { + const h = [{ at: t0.toISOString(), bytes: 1 }]; + assert.deepEqual(hz.carryTraffic(null, h, new Date(t0.getTime() + DAY)), h); + }); + test("carryTimes keeps it from read to read", () => { + const a = hz.carryTimes([server({ outgoingTraffic: 1 * TB })], [], t0); + const b = hz.carryTimes([server({ outgoingTraffic: 2 * TB })], a, new Date(t0.getTime() + 7 * HOUR)); + assert.deepEqual(b[0].trafficHistory?.map((x) => x.bytes), [1 * TB, 2 * TB]); + }); +}); + +describe("the traffic forecast", () => { + const NOW = Date.parse("2026-06-11T00:00:00Z"); // ten days into a month of thirty + const sample = (daysAgo: number, bytes: number) => ({ at: iso(NOW - daysAgo * DAY), bytes }); + const s = (used: number, history: { at: string; bytes: number }[] = [], included = 20 * TB) => ({ outgoingTraffic: used, includedTraffic: included, trafficHistory: history }); + + test("by the month's average when there is no recent history: 10 TB in ten days is 1 TB a day, and 30 TB at the month's end — the quota goes on the 21st", () => { + const f = hz.trafficForecast(s(10 * TB), NOW)!; + assert.equal(f.basis, "month"); + assert.equal(Math.round(f.perDay / TB), 1); + assert.equal(Math.round(f.projectedMonth / TB), 30); + assert.equal(f.exhaustedAt && hz.dayText(f.exhaustedAt), "21 June"); + }); + + test("by the last week's rate when there is some: a rate that has gone up counts", () => { + // 4 TB by day 4 (seven days ago is before the month's start, so the sample at day 4 is the oldest in the window), then 10 TB now: 1 TB a day. + const f = hz.trafficForecast(s(10 * TB, [sample(6, 4 * TB), sample(3, 6 * TB)]), NOW)!; + assert.equal(f.basis, "recent"); + assert.equal(Math.round(f.perDay / TB), 1); + // The last three days were quicker than the month: 6 -> 10 TB over 3 days is 1.33 TB a day, and that is what the oldest sample in a three-day window gives. + const fast = hz.trafficForecast(s(10 * TB, [sample(3, 6 * TB)]), NOW)!; + assert.equal(fast.basis, "recent"); + assert.ok(fast.perDay > 1.2 * TB && fast.perDay < 1.5 * TB); + }); + + test("a forecast that stays under the quota has no date; a quota already passed has none either", () => { + const calm = hz.trafficForecast(s(2 * TB), NOW)!; + assert.deepEqual([calm.exhaustedAt, Math.round(calm.projectedMonth / TB)], [null, 6]); + assert.equal(hz.trafficForecast(s(21 * TB), NOW)!.exhaustedAt, null); + }); + + test("too little to say: the first days of a month, a server with no quota or no traffic, a counter that says nothing", () => { + const early = Date.parse("2026-06-02T00:00:00Z"); + assert.equal(hz.trafficForecast(s(1 * TB), early), null); + assert.equal(hz.trafficForecast(s(0), NOW), null); + assert.equal(hz.trafficForecast({ outgoingTraffic: null, includedTraffic: 20 * TB }, NOW), null); + assert.equal(hz.trafficForecast({ outgoingTraffic: 5 * TB, includedTraffic: null }, NOW), null); + }); + + test("samples from last month, or higher than now, are not used", () => { + const f = hz.trafficForecast(s(10 * TB, [sample(20, 19 * TB), sample(5, 30 * TB)]), NOW)!; + assert.equal(f.basis, "month"); + }); +}); + +describe("what is wrong, the second round", () => { + const NOW = Date.parse("2026-06-11T00:00:00Z"); + const stored = (extra: Partial = {}, hist: { at: string; bytes: number }[] = []) => ({ ...server(extra), lastRunningAt: iso(NOW - HOUR), statusSince: iso(NOW - HOUR), rescueSince: null, trafficHistory: hist }); + const keys = (list: ReturnType) => list.map((p) => `${p.key}=${p.severity}`); + const problems = (extras: import("../src/services/hetznerSync.js").HetznerExtras, servers = [stored()]) => hz.hetznerProblems(1, "Prod", servers, [], NOW, 48, extras); + + describe("load balancers", () => { + test("healthy says nothing; one unhealthy target is a warning naming it; all of them is critical; an unknown is not unhealthy", () => { + assert.deepEqual(problems({ loadBalancers: [lb()] }), []); + const one = problems({ loadBalancers: [lb({ targets: [{ kind: "server", serverId: 1, label: null, health: "healthy" }, { kind: "server", serverId: 2, label: null, health: "unhealthy" }] })] }, [stored(), stored({ id: 2, name: "api" })]); + assert.deepEqual(keys(one), ["hetzner-lb:1:10=warning"]); + assert.match(one[0].message, /Prod: load balancer front has 1 of 2 targets unhealthy \(api\)$/); + const all = problems({ loadBalancers: [lb({ targets: [{ kind: "server", serverId: 1, label: null, health: "unhealthy" }] })] }); + assert.deepEqual(keys(all), ["hetzner-lb:1:10=critical"]); + assert.match(all[0].message, /nothing healthy to send to/); + assert.deepEqual(problems({ loadBalancers: [lb({ targets: [{ kind: "server", serverId: 1, label: null, health: "unknown" }] })] }), []); + assert.deepEqual(problems({ loadBalancers: null }), []); + }); + }); + + describe("certificates", () => { + test("far from the end is fine; within two weeks is a warning, within three days critical, past the end critical; the message says who must renew it", () => { + assert.deepEqual(problems({ certificates: [cert()] }), []); + const soon = problems({ certificates: [cert({ notValidAfter: iso(NOW + 10 * DAY) })] }); + assert.deepEqual(keys(soon), ["hetzner-cert:1:20=warning"]); + assert.match(soon[0].message, /certificate site \(example\.se, www\.example\.se\) ends in 10 days — Hetzner should have renewed it/); + assert.deepEqual(keys(problems({ certificates: [cert({ notValidAfter: iso(NOW + 2 * DAY), type: "uploaded" })] })), ["hetzner-cert:1:20=critical"]); + assert.match(problems({ certificates: [cert({ notValidAfter: iso(NOW + 2 * DAY), type: "uploaded" })] })[0].message, /uploaded, so it has to be renewed by hand/); + const gone = problems({ certificates: [cert({ notValidAfter: iso(NOW - 3 * DAY) })] }); + assert.deepEqual(keys(gone), ["hetzner-cert:1:20=critical"]); + assert.match(gone[0].message, /ended 3 days ago/); + }); + test("a managed one that could not be issued or renewed says why; one nothing uses is not news; an unknown end or an unread list says nothing", () => { + const failed = problems({ certificates: [cert({ renewal: "failed", error: "DNS did not answer", notValidAfter: iso(NOW + 59 * DAY + HOUR) })] }); + assert.deepEqual(keys(failed), ["hetzner-cert:1:20=warning"]); + assert.match(failed[0].message, /could not be renewed by Hetzner — DNS did not answer \(it is valid for 59 more days\)/); + assert.deepEqual(problems({ certificates: [cert({ notValidAfter: iso(NOW + DAY), usedBy: 0 })] }), []); + assert.deepEqual(problems({ certificates: [cert({ notValidAfter: null })] }), []); + assert.deepEqual(problems({ certificates: null }), []); + }); + }); + + describe("floating IPs", () => { + test("one that points at a server is fine; one that points at none is a warning (it is billed)", () => { + assert.deepEqual(problems({ floatingIps: [fip()] }), []); + const free = problems({ floatingIps: [fip({ serverId: null })] }); + assert.deepEqual(keys(free), ["hetzner-fip:1:30=warning"]); + assert.match(free[0].message, /floating IP 203\.0\.113\.60 \(vip\) points at no server — it is billed all the same/); + }); + }); + + describe("the traffic forecast", () => { + test("on course to pass the quota is a warning with the date, the rate and what it is made from; the traffic alert takes over from 80%", () => { + const p = problems({}, [stored({ outgoingTraffic: 10 * TB })]); + assert.deepEqual(keys(p), ["hetzner-forecast:1:1=warning"]); + assert.match(p[0].message, /Prod: at this rate web will pass its 20\.0 TB traffic quota on 21 June — it has sent 10\.0 TB so far, about 1\.0 TB a day \(the month's average\)/); + assert.deepEqual(keys(problems({}, [stored({ outgoingTraffic: 17 * TB })])), ["hetzner-traffic:1:1=warning"], "no forecast beside the traffic alert"); + assert.deepEqual(problems({}, [stored({ outgoingTraffic: 3 * TB })]), []); + }); + }); +}); + +describe("the health pass, the page and /metrics", () => { + let id = 0; + let app: Server; + let base = ""; + const fresh = () => setInternalFlag("hetznerSync", JSON.stringify({ [id]: { at: new Date().toISOString(), ok: true, error: null } })); + const stale = () => setInternalFlag("hetznerSync", JSON.stringify({ [id]: { at: new Date(Date.now() - 30 * MIN).toISOString(), ok: true, error: null } })); + const sick = lb({ id: 11, name: "api-lb", targets: [{ kind: "server", serverId: 2, label: null, health: "unhealthy" }] }); + + before(async () => { + await db.insert(users).values([{ oidcSub: "viewer", name: "Vic", role: "viewer" }]); + id = (await db.insert(integrations).values({ type: "hetzner", name: "Prod project", baseUrl: "https://api.hetzner.cloud", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + // web has used 11 TB of 20 and the month is a few days old at least: a forecast either way is not what is tested here, so give it nothing. + const read: Read = { + servers: [server({ id: 1, name: "web", outgoingTraffic: 1 * TB }), server({ id: 2, name: "api", ipv4: "203.0.113.9" })], + volumes: [], + images: [], + primaryIps: [], + prices: PRICES, + loadBalancers: [lb(), sick], + floatingIps: [fip(), fip({ id: 31, ip: "203.0.113.61", serverId: null })], + certificates: [cert({ notValidAfter: iso(Date.now() + 5 * DAY) }), cert({ id: 21, name: "unused", notValidAfter: iso(Date.now() + DAY), usedBy: 0 })], + }; + await hz.storeRead(id, read, new Date()); + await fresh(); + const a = express(); + a.use((req, _res, next) => { + (req as unknown as { session: unknown }).session = { user: { sub: "viewer" } }; + next(); + }); + a.use("/api/hetzner", hetznerRouter); + app = await new Promise((resolve) => { + const s = a.listen(0, "127.0.0.1", () => resolve(s)); + }); + base = `http://127.0.0.1:${(app.address() as AddressInfo).port}/api/hetzner`; + }); + after(() => { + app.close(); + try { + rmSync(dir, { recursive: true, force: true }); + } catch { + // Windows keeps the database file locked until the process exits. + } + }); + + test("they are stored (an unread list as null) and come back", async () => { + const body = (await (await fetch(base)).json()) as { projects: { id: number; state: { loadBalancers: { name: string; targets: { serverName: string | null }[] }[] | null; floatingIps: { ip: string; serverName: string | null }[]; certificates: { name: string }[]; cost: { loadBalancers: number; floatingIps: number }; servers: { name: string; trafficHistory?: unknown; forecast: unknown }[] } }[] }; + const p = body.projects.find((x) => x.id === id)!; + assert.deepEqual(p.state.loadBalancers?.map((l) => [l.name, l.targets[0].serverName]), [["front", "web"], ["api-lb", "api"]]); + assert.deepEqual(p.state.floatingIps.map((f) => [f.ip, f.serverName]), [["203.0.113.60", "web"], ["203.0.113.61", null]]); + assert.deepEqual(p.state.certificates.map((c) => c.name), ["site", "unused"]); + assert.deepEqual([p.state.cost.loadBalancers, p.state.cost.floatingIps], [12, 7]); + assert.ok(p.state.servers.every((s) => s.trafficHistory === undefined), "the history is not sent to the page"); + }); + + test("the health pass judges them, and maintenance on the integration silences them", async () => { + const { snapshot } = await collectSnapshot(); + const list = evaluateHealth(snapshot, { serverOfflineMinutes: 60, diskUsagePercent: 90 }, Date.now(), { skipServers: true }); + const mine = list.filter((x) => /^hetzner-(lb|cert|fip):/.test(x.key)).map((x) => `${x.key}=${x.severity}`).sort(); + assert.deepEqual(mine, [`hetzner-cert:${id}:20=warning`, `hetzner-fip:${id}:31=warning`, `hetzner-lb:${id}:11=critical`].sort(), "the certificate nothing uses is left out"); + for (const k of ["lb", "cert", "fip", "forecast"]) assert.equal(subjectOfConditionKey(`hetzner-${k}:${id}:5`), `integration:${id}`); + }); + + test("the Alerts page says where to look", async () => { + invalidateAlertsCache(); + const report = await getAlerts(true); + const find = (kind: string, n: number) => report.alerts.find((x) => x.id.endsWith(`hetzner-${kind}:${id}:${n}`))!; + assert.deepEqual([find("lb", 11).category, find("cert", 20).category, find("fip", 31).category, find("lb", 11).link], ["services", "services", "services", "/hetzner"]); + }); + + test("/metrics has each load balancer's unhealthy targets and each certificate's end — only while the reading is recent", async () => { + let text = await buildMetrics(new Date()); + assert.match(text, /homelab_hetzner_load_balancer_unhealthy_targets\{project="Prod project",load_balancer="api-lb"\} 1/); + assert.match(text, /homelab_hetzner_load_balancer_unhealthy_targets\{project="Prod project",load_balancer="front"\} 0/); + assert.match(text, /homelab_hetzner_certificate_expiry_timestamp_seconds\{project="Prod project",certificate="site"\} \d/); + await stale(); + text = await buildMetrics(new Date()); + assert.doesNotMatch(text, /homelab_hetzner/); + await fresh(); + }); +}); diff --git a/web/src/App.tsx b/web/src/App.tsx index abb9299..427ea6a 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -21,6 +21,7 @@ import NetBox from "./pages/NetBox"; import Nextcloud from "./pages/Nextcloud"; import Hetzner from "./pages/Hetzner"; import GameServers from "./pages/GameServers"; +import Media from "./pages/Media"; import Speedtest from "./pages/Speedtest"; import Costs from "./pages/Costs"; import ServiceLevels from "./pages/ServiceLevels"; @@ -180,6 +181,7 @@ function Shelled({ user }: { user: CurrentUser }) { } /> } /> } /> + } /> } /> } /> } /> diff --git a/web/src/api/client.ts b/web/src/api/client.ts index 2fae903..a812eba 100644 --- a/web/src/api/client.ts +++ b/web/src/api/client.ts @@ -1285,6 +1285,55 @@ export interface HetznerServerInfo { lastRunningAt: string | null; statusSince: string; rescueSince: string | null; + /** How the month's traffic is forecast to end; null when there is too little to say. */ + forecast?: HetznerTrafficForecast | null; +} + +export interface HetznerTrafficForecast { + /** Bytes a day, the way it has been going. */ + perDay: number; + /** What the month will have come to by its end at that rate. */ + projectedMonth: number; + /** When the quota is passed, if that is before the month ends. */ + exhaustedAt: string | null; + basis: "recent" | "month"; +} + +export interface HetznerLoadBalancerInfo { + id: number; + name: string; + type: string | null; + location: string | null; + ipv4: string | null; + algorithm: string | null; + services: number; + targets: { kind: "server" | "label_selector" | "ip"; serverId: number | null; serverName: string | null; label: string | null; health: "healthy" | "unhealthy" | "unknown" }[]; + includedTraffic: number | null; + outgoingTraffic: number | null; + monthlyPrice: number | null; +} + +export interface HetznerFloatingIpInfo { + id: number; + name: string | null; + ip: string; + type: "ipv4" | "ipv6"; + serverId: number | null; + serverName: string | null; + location: string | null; + description: string | null; +} + +export interface HetznerCertificateInfo { + id: number; + name: string; + type: string; + domains: string[]; + notValidAfter: string | null; + issuance: string | null; + renewal: string | null; + error: string | null; + usedBy: number; } export interface HetznerProblemInfo { @@ -1307,7 +1356,11 @@ export interface HetznerProject { /** Null when the volumes could not be listed, which is not the same as none. */ volumes: { id: number; name: string; size: number; serverId: number | null; serverName: string | null; location: string | null; status: string }[] | null; images: { id: number; type: "snapshot" | "backup"; description: string | null; created: string | null; sizeGb: number | null; serverId: number | null; serverName: string | null }[] | null; - cost: { currency: string; servers: number; backups: number; volumes: number; snapshots: number; ips: number; total: number; unassignedIps: number; unpriced: number } | null; + cost: { currency: string; servers: number; backups: number; volumes: number; snapshots: number; ips: number; loadBalancers?: number; floatingIps?: number; total: number; unassignedIps: number; unpriced: number } | null; + /** Each of these is null when it could not be listed, which is not the same as none. */ + loadBalancers: HetznerLoadBalancerInfo[] | null; + floatingIps: HetznerFloatingIpInfo[] | null; + certificates: HetznerCertificateInfo[] | null; updatedAt: string; } | null; problems: HetznerProblemInfo[]; @@ -1323,6 +1376,7 @@ export interface HetznerForServer { newestBackup: string | null; snapshots: number; problems: HetznerProblemInfo[]; + forecast: HetznerTrafficForecast | null; } | null; } @@ -1375,6 +1429,31 @@ export interface FragnetAccount { problems: { key: string; serverId: string; message: string; severity: "warning" | "critical" }[]; } +/** One Sonarr, Radarr or Prowlarr (an integration of that type), as the media page shows it. */ +export interface ArrApp { + id: number; + kind: "sonarr" | "radarr" | "prowlarr"; + name: string; + enabled: boolean; + url: string; + status: { at: string; ok: boolean; error: string | null } | null; + fresh: boolean; + state: { + version: string | null; + /** What its own checks found: type is ok, notice, warning or error. */ + health: { source: string; type: string; message: string }[]; + /** Null when it could not be read (and always for Prowlarr, which has none). */ + queue: { total: number; items: { id: number; title: string; status: string; tracked: "ok" | "warning" | "error" | null; state: string | null; messages: string[]; size: number | null; sizeLeft: number | null; added: string | null; etaAt: string | null; protocol: string | null; client: string | null; indexer: string | null }[] } | null; + disks: { path: string; label: string | null; free: number; total: number }[] | null; + missing: number | null; + indexers: { id: number; name: string; enabled: boolean; protocol: string | null; disabledTill: string | null; lastFailure: string | null }[] | null; + updatedAt: string; + /** The ids of the queue items that are stuck. */ + stuck: number[]; + } | null; + problems: { key: string; message: string; severity: "warning" | "critical" }[]; +} + export type FragnetSignal = "start" | "stop" | "restart" | "kill"; export interface CostItem { @@ -2495,7 +2574,7 @@ export interface ManualTaskInput { enabled?: boolean; } -export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless" | "nextcloud" | "netbox" | "n8n" | "hetzner" | "speedtest" | "fragnet"; +export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless" | "nextcloud" | "netbox" | "n8n" | "hetzner" | "speedtest" | "fragnet" | "sonarr" | "radarr" | "prowlarr"; export interface IntegrationField { key: string; @@ -3090,6 +3169,9 @@ export const api = { list: () => request<{ speedtests: SpeedtestInfo[] }>("/api/speedtest"), history: (id: number, days: number) => request(`/api/speedtest/${id}/history?days=${days}`), }, + arr: { + list: () => request<{ apps: ArrApp[] }>("/api/arr"), + }, fragnet: { list: () => request<{ accounts: FragnetAccount[] }>("/api/fragnet"), power: (integrationId: number, serverId: string, signal: FragnetSignal) => request(`/api/fragnet/${integrationId}/servers/${serverId}/power`, { method: "POST", body: JSON.stringify({ signal }) }), diff --git a/web/src/components/HetznerServerCard.tsx b/web/src/components/HetznerServerCard.tsx index b08c9e1..d17f937 100644 --- a/web/src/components/HetznerServerCard.tsx +++ b/web/src/components/HetznerServerCard.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { api, type HetznerForServer } from "../api/client"; import TimeAgo from "./TimeAgo"; -import { StatusBadge, TrafficBar } from "../pages/Hetzner"; +import { ForecastText, StatusBadge, TrafficBar } from "../pages/Hetzner"; /** On a server's page: the Hetzner Cloud server it is (matched by address, else by name), when there is one. Nothing is shown for a server that is not at Hetzner. */ export default function HetznerServerCard({ serverId }: { serverId: number }) { @@ -57,6 +57,7 @@ export default function HetznerServerCard({ serverId }: { serverId: number }) {
Traffic this month
+
diff --git a/web/src/components/WallView.tsx b/web/src/components/WallView.tsx index 28e2396..1c33edc 100644 --- a/web/src/components/WallView.tsx +++ b/web/src/components/WallView.tsx @@ -30,6 +30,9 @@ const TYPE_LABELS: Record = { hetzner: "Hetzner Cloud", speedtest: "Speedtest Tracker", fragnet: "Fragnet game servers", + sonarr: "Sonarr", + radarr: "Radarr", + prowlarr: "Prowlarr", }; export type WallLevel = "critical" | "warning" | "ok" | "unsure"; diff --git a/web/src/layout/nav.tsx b/web/src/layout/nav.tsx index 579df28..09d3985 100644 --- a/web/src/layout/nav.tsx +++ b/web/src/layout/nav.tsx @@ -20,6 +20,7 @@ import { IconCloud, IconBinaryTree, IconDeviceGamepad2, + IconDeviceTv, IconServerBolt, IconBolt, IconFileText, @@ -109,6 +110,7 @@ export const NAV: NavEntry[] = [ items: [ { to: "/home-assistant", label: "Home Assistant", icon: }, { to: "/jellyfin", label: "Jellyfin", icon: }, + { to: "/media", label: "Media managers", icon: }, { to: "/immich", label: "Immich", icon: }, { to: "/paperless", label: "Paperless", icon: }, { to: "/nextcloud", label: "Nextcloud", icon: }, diff --git a/web/src/pages/Hetzner.tsx b/web/src/pages/Hetzner.tsx index 97733c2..67a4ded 100644 --- a/web/src/pages/Hetzner.tsx +++ b/web/src/pages/Hetzner.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; -import { api, type HetznerProject } from "../api/client"; +import { api, type HetznerProject, type HetznerTrafficForecast } from "../api/client"; import EmptyState from "../components/EmptyState"; import TimeAgo from "../components/TimeAgo"; import { BlockSkeleton } from "../components/Skeleton"; @@ -23,6 +23,22 @@ export function StatusBadge({ status }: { status: string }) { return {status}; } +const DAY_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; +const dayText = (iso: string) => { + const d = new Date(iso); + return `${d.getUTCDate()} ${DAY_NAMES[d.getUTCMonth()]}`; +}; + +/** What the month's traffic is forecast to come to, and when the quota goes if it is before the month ends. */ +export function ForecastText({ forecast, included }: { forecast: HetznerTrafficForecast | null | undefined; included: number | null }) { + if (!forecast || included === null || included <= 0) return null; + return ( +
+ {forecast.exhaustedAt ? <>at this rate the quota is passed on {dayText(forecast.exhaustedAt)} : <>on course for {formatBytes(forecast.projectedMonth)} by the month’s end} · {formatBytes(forecast.perDay)} a day ({forecast.basis === "recent" ? "this week" : "the month"}) +
+ ); +} + /** This month's outgoing traffic against what the server includes, as a bar that turns yellow at 80% and red at 100%. */ export function TrafficBar({ used, included }: { used: number | null; included: number | null }) { if (used === null || included === null || included <= 0) return {used === null ? "—" : formatBytes(used)}; @@ -76,6 +92,7 @@ function ServerRow({ s }: { s: NonNullable["servers"][n + {s.backupWindow ? `on (${s.backupWindow})` : "off"} {s.monthlyPrice === null ? "—" : s.monthlyPrice.toFixed(2)} @@ -150,8 +167,8 @@ function Card({ p }: { p: HetznerProject }) {
{cost && (
- Servers {money(cost.servers, cost.currency)} · backups {money(cost.backups, cost.currency)} · volumes {money(cost.volumes, cost.currency)} · snapshots {money(cost.snapshots, cost.currency)} · primary IPs {money(cost.ips, cost.currency)} - {cost.unassignedIps > 0 ? ` (${cost.unassignedIps} not attached to a server)` : ""}. An estimate from Hetzner’s price list: it leaves out load balancers, floating IPs and traffic over the quota{cost.unpriced > 0 ? `, and ${cost.unpriced} server(s) whose price was not given` : ""}. + Servers {money(cost.servers, cost.currency)} · backups {money(cost.backups, cost.currency)} · volumes {money(cost.volumes, cost.currency)} · snapshots {money(cost.snapshots, cost.currency)} · primary IPs {money(cost.ips, cost.currency)} · load balancers {money(cost.loadBalancers ?? 0, cost.currency)} · floating IPs {money(cost.floatingIps ?? 0, cost.currency)} + {cost.unassignedIps > 0 ? ` (${cost.unassignedIps} not attached to a server)` : ""}. An estimate from Hetzner’s price list: it leaves out traffic over the quota{cost.unpriced > 0 ? `, and ${cost.unpriced} server(s) whose price was not given` : ""}.
)}
@@ -182,6 +199,96 @@ function Card({ p }: { p: HetznerProject }) {
+ {s.loadBalancers && s.loadBalancers.length > 0 && ( + <> +

Load balancers

+
+ + + + + + + + + + + + + {s.loadBalancers.map((l) => { + const bad = l.targets.filter((t) => t.health === "unhealthy"); + return ( + + + + + + + + + ); + })} + +
NameTypeAddressTargetsTraffic this monthPrice/mo
+ {l.name} +
+ {l.services} service{l.services === 1 ? "" : "s"} + {l.algorithm ? ` · ${l.algorithm.replace("_", " ")}` : ""} +
+
{[l.type, l.location].filter(Boolean).join(" · ") || "—"}{l.ipv4 ?? "—"} + {l.targets.length === 0 ? ( + none + ) : bad.length === 0 ? ( + {l.targets.every((t) => t.health === "healthy") ? `${l.targets.length} healthy` : `${l.targets.length} · not judged yet`} + ) : ( + {bad.length} of {l.targets.length} unhealthy + )} +
{l.targets.map((t) => `${t.serverName ?? t.label ?? "target"}${t.health === "unhealthy" ? " ✗" : ""}`).join(", ")}
+
+ + {l.monthlyPrice === null ? "—" : l.monthlyPrice.toFixed(2)}
+
+ + )} + {s.floatingIps && s.floatingIps.length > 0 && ( + <> +

Floating IPs

+
    + {s.floatingIps.map((f) => ( +
  • + {f.ip} + {f.name ? ` (${f.name})` : ""} — {f.serverId === null ? points at no server (still billed) : f.serverName ? `points at ${f.serverName}` : `points at a server (#${f.serverId})`} + {f.location ? `, ${f.location}` : ""} +
  • + ))} +
+ + )} + {s.certificates && s.certificates.length > 0 && ( + <> +

Certificates

+
    + {s.certificates.map((c) => { + const left = c.notValidAfter === null ? null : (Date.parse(c.notValidAfter) - Date.now()) / 86_400_000; + return ( +
  • + {c.name} ({c.type} + {c.domains.length > 0 ? `, ${c.domains.slice(0, 3).join(", ")}${c.domains.length > 3 ? ", …" : ""}` : ""}) —{" "} + {c.notValidAfter === null ? ( + {c.issuance === "failed" ? "could not be issued" : "being issued"} + ) : left !== null && left <= 0 ? ( + ended + ) : ( + ends in {Math.ceil(left ?? 0)} days + )} + {c.usedBy === 0 && · used by nothing} + {(c.issuance === "failed" || c.renewal === "failed") && · {c.issuance === "failed" ? "issuing" : "renewing"} failed{c.error ? `: ${c.error}` : ""}} +
  • + ); + })} +
+ + )} {s.volumes && s.volumes.length > 0 && ( <>

Volumes

@@ -241,7 +348,7 @@ export default function Hetzner() {

Hetzner Cloud

One project per integration, read every few minutes (see Integrations) — nothing is started, stopped or changed. A server that was running and is now off, traffic close to the month’s quota,{" "} - rescue mode left on and backups that are late are alerts — see Alerts. + rescue mode left on, backups that are late, a traffic quota the month is on course to pass, unhealthy load balancer targets, certificates about to end and floating IPs that point at nothing are alerts — see Alerts.

{!data && !error && } diff --git a/web/src/pages/Media.tsx b/web/src/pages/Media.tsx new file mode 100644 index 0000000..d0e1bd0 --- /dev/null +++ b/web/src/pages/Media.tsx @@ -0,0 +1,232 @@ +import { useEffect, useState } from "react"; +import { Link } from "react-router-dom"; +import { api, type ArrApp } from "../api/client"; +import EmptyState from "../components/EmptyState"; +import TimeAgo from "../components/TimeAgo"; +import { BlockSkeleton } from "../components/Skeleton"; +import { ErrorNotice } from "../components/Notice"; +import { formatBytes } from "./settings/StorageSettings"; +import { readableError } from "../utils/errors"; + +const KIND_NAMES: Record = { sonarr: "Sonarr", radarr: "Radarr", prowlarr: "Prowlarr" }; +const QUEUE_SHOWN = 25; + +function Badge({ a }: { a: ArrApp }) { + if (!a.enabled) return Off; + if (!a.state) return Not read yet; + if (!a.fresh) return Can’t be read; + if (a.problems.some((x) => x.severity === "critical")) return Needs a look; + if (a.problems.length > 0) return Needs a look; + return In order; +} + +function Tile({ label, value, sub, warn }: { label: string; value: string; sub?: string | null; warn?: boolean }) { + return ( +
+
+
+
{label}
+
{value}
+ {sub &&
{sub}
} +
+
+
+ ); +} + +function Card({ a }: { a: ArrApp }) { + const s = a.state; + const stuck = new Set(s?.stuck ?? []); + const queue = s?.queue ?? null; + const items = queue ? [...queue.items].sort((x, y) => Number(stuck.has(y.id)) - Number(stuck.has(x.id)) || Date.parse(x.added ?? "") - Date.parse(y.added ?? "")) : []; + const findings = (s?.health ?? []).filter((h) => h.type === "warning" || h.type === "error"); + const notices = (s?.health ?? []).filter((h) => h.type === "notice"); + return ( +
+
+

+ {a.name} {KIND_NAMES[a.kind]}{s?.version ? ` ${s.version}` : ""} +

+
{a.status ? <>read : "not read yet"}
+
+
+ {a.status && !a.status.ok &&
The last attempt to read it failed: {a.status.error ?? "no answer"}.
} + {a.problems.length > 0 && ( +
    + {a.problems.map((x) => ( +
  • + {x.message} +
  • + ))} +
+ )} + {s && ( + <> +
+ {a.kind !== "prowlarr" && ( + <> + 0 ? `${stuck.size} stuck` : "nothing stuck") : "could not be read"} warn={stuck.size > 0} /> + + + )} + {a.kind === "prowlarr" && ( + <> + i.enabled).length} switched on` : "could not be read"} /> + i.disabledTill && Date.parse(i.disabledTill) > Date.now()).length) : "—"} sub="switched off after failures" warn={!!s.indexers?.some((i) => i.disabledTill && Date.parse(i.disabledTill) > Date.now())} /> + + )} + 0 ? `and ${notices.length} notice${notices.length === 1 ? "" : "s"}` : "warnings and errors"} warn={findings.length > 0} /> + 0 ? `${formatBytes(Math.min(...s.disks.map((d) => d.free)))} free on the fullest` : "none reported") : "could not be read"} /> +
+ {(findings.length > 0 || notices.length > 0) && ( + <> +

What {KIND_NAMES[a.kind]} says

+
    + {[...findings, ...notices].map((h, i) => ( +
  • + {h.type} {h.message} +
  • + ))} +
+ + )} + {s.disks && s.disks.length > 0 && ( +
+

Disks

+ {s.disks.map((d) => { + const free = d.total > 0 ? d.free / d.total : 1; + return ( +
+
+
+
+
+ {d.path} {formatBytes(d.free)} free of {formatBytes(d.total)} ({Math.floor(free * 100)}%) +
+
+ ); + })} +
+ )} + {queue && queue.total > 0 && ( + <> +

Download queue

+
+ + + + + + + + + + + + {items.slice(0, QUEUE_SHOWN).map((i) => { + const done = i.size && i.size > 0 && i.sizeLeft !== null ? Math.round(((i.size - i.sizeLeft) / i.size) * 100) : null; + const isStuck = stuck.has(i.id); + return ( + + + + + + + + ); + })} + +
TitleStateProgressIn the queueClient
+ {i.title} + {i.messages.map((m) => ( +
+ {m} +
+ ))} +
+ {isStuck ? stuck : i.tracked === "warning" || i.tracked === "error" ? {i.tracked} : {i.status}} + {i.state && i.state !== "downloading" &&
{i.state}
} +
+ {done === null ? ( + — + ) : ( + <> +
+
+
+
+ {done}%{i.size ? ` of ${formatBytes(i.size)}` : ""} +
+ + )} +
+ + + {i.client ?? "—"} + {i.indexer &&
{i.indexer}
} +
+
+ {queue.total > QUEUE_SHOWN &&
{queue.total - QUEUE_SHOWN} more are in the queue (the stuck ones are listed first).
} + + )} + {s.indexers && s.indexers.length > 0 && ( + <> +

Indexers

+
    + {s.indexers.map((i) => { + const off = i.disabledTill !== null && Date.parse(i.disabledTill) > Date.now(); + return ( +
  • + {i.name} {i.protocol && {i.protocol}}{" "} + {!i.enabled ? off : off ? failing, tried again : working} +
  • + ); + })} +
+ + )} + + )} +
+
+ ); +} + +/** Sonarr, Radarr and Prowlarr: what each says is wrong, the downloads that are stuck, the disks they fill and the indexers that have failed. */ +export default function Media() { + const [data, setData] = useState(null); + const [error, setError] = useState(null); + useEffect(() => { + const load = () => + api.arr + .list() + .then((r) => { + setData(r.apps); + setError(null); + }) + .catch((err) => setError(readableError(err))); + void load(); + const t = setInterval(load, 60_000); + return () => clearInterval(t); + }, []); + return ( + <> +

Media managers

+

+ Sonarr, Radarr and Prowlarr, read every few minutes (see Integrations) — nothing is searched, grabbed or changed. What an application says is wrong with itself, downloads stuck for two hours and{" "} + a disk nearly full are alerts — see Alerts. +

+ + {!data && !error && } + {data && data.length === 0 && ( +
+
+ +
+
+ )} + {data?.map((a) => )} + + ); +} diff --git a/web/src/utils/integrationTypes.ts b/web/src/utils/integrationTypes.ts index 0dc37e8..652f648 100644 --- a/web/src/utils/integrationTypes.ts +++ b/web/src/utils/integrationTypes.ts @@ -27,6 +27,9 @@ export const TYPE_LABELS: Record = { hetzner: "Hetzner Cloud", speedtest: "Speedtest Tracker", fragnet: "Fragnet game servers", + sonarr: "Sonarr", + radarr: "Radarr", + prowlarr: "Prowlarr", }; /** The page each kind of integration gets once it is connected. */ @@ -56,12 +59,15 @@ export const TYPE_PAGES: Record = { hetzner: "/hetzner", speedtest: "/speedtest", fragnet: "/game-servers", + sonarr: "/media", + radarr: "/media", + prowlarr: "/media", }; /** The kinds of integration grouped the way the sidebar groups their pages, in the same order. */ export const TYPE_GROUPS: { id: string; label: string; types: IntegrationType[] }[] = [ { id: "infrastructure", label: "Infrastructure", types: ["proxmox", "synology", "dockhand", "hetzner", "fragnet", "tailscale"] }, - { id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "immich", "paperless", "nextcloud", "authentik"] }, + { id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "prowlarr", "immich", "paperless", "nextcloud", "authentik"] }, { id: "backups", label: "Backups", types: ["pbs"] }, { id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox"] }, { id: "monitoring", label: "Monitoring", types: ["uptimekuma", "prometheus", "ups", "speedtest"] },