diff --git a/server/drizzle/0081_powerful_thing.sql b/server/drizzle/0081_powerful_thing.sql new file mode 100644 index 0000000..2459742 --- /dev/null +++ b/server/drizzle/0081_powerful_thing.sql @@ -0,0 +1,16 @@ +CREATE TABLE `technitium_state` ( + `integration_id` integer PRIMARY KEY NOT NULL, + `version` text, + `started_at` text, + `dns_port` integer DEFAULT 53 NOT NULL, + `blocking_enabled` integer DEFAULT true NOT NULL, + `blocking_off_since` text, + `settings` text NOT NULL, + `stats` text, + `zones` text, + `dhcp` text, + `probe` text, + `probe_fail_since` 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/0081_snapshot.json b/server/drizzle/meta/0081_snapshot.json new file mode 100644 index 0000000..e14127a --- /dev/null +++ b/server/drizzle/meta/0081_snapshot.json @@ -0,0 +1,8639 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "71c78aaa-981b-4b44-b493-80fde4458e6c", + "prevId": "05b2cbfa-2fcf-42ea-8cee-7304839c2fd2", + "tables": { + "adguard_state": { + "name": "adguard_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 + }, + "running": { + "name": "running", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "protection_enabled": { + "name": "protection_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "protection_off_since": { + "name": "protection_off_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dns_port": { + "name": "dns_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 53 + }, + "stats": { + "name": "stats", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "filters": { + "name": "filters", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe": { + "name": "probe", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe_fail_since": { + "name": "probe_fail_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "adguard_state_integration_id_integrations_id_fk": { + "name": "adguard_state_integration_id_integrations_id_fk", + "tableFrom": "adguard_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "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_kind_runbooks": { + "name": "alert_kind_runbooks", + "columns": { + "kind": { + "name": "kind", + "type": "text", + "primaryKey": true, + "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, + "default": "''" + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "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": {}, + "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": "'[]'" + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images_at": { + "name": "images_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "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": {} + }, + "grafana_state": { + "name": "grafana_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 + }, + "rules": { + "name": "rules", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "datasources": { + "name": "datasources", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "grafana_state_integration_id_integrations_id_fk": { + "name": "grafana_state_integration_id_integrations_id_fk", + "tableFrom": "grafana_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": {} + }, + "port_presets": { + "name": "port_presets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ports": { + "name": "ports", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "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": { + "port_presets_name_unique": { + "name": "port_presets_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "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": {} + }, + "release_cache": { + "name": "release_cache", + "columns": { + "repo": { + "name": "repo", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "published_at": { + "name": "published_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "checked_at": { + "name": "checked_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "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_container_ports": { + "name": "server_container_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'" + }, + "container": { + "name": "container", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "server_container_ports_unique": { + "name": "server_container_ports_unique", + "columns": [ + "server_id", + "port", + "protocol" + ], + "isUnique": true + } + }, + "foreignKeys": { + "server_container_ports_server_id_servers_id_fk": { + "name": "server_container_ports_server_id_servers_id_fk", + "tableFrom": "server_container_ports", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "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": {} + }, + "technitium_state": { + "name": "technitium_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 + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dns_port": { + "name": "dns_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 53 + }, + "blocking_enabled": { + "name": "blocking_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "blocking_off_since": { + "name": "blocking_off_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "settings": { + "name": "settings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stats": { + "name": "stats", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "zones": { + "name": "zones", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dhcp": { + "name": "dhcp", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe": { + "name": "probe", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe_fail_since": { + "name": "probe_fail_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "technitium_state_integration_id_integrations_id_fk": { + "name": "technitium_state_integration_id_integrations_id_fk", + "tableFrom": "technitium_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "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 + }, + "server_page_layout": { + "name": "server_page_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 36c88fa..4564b3a 100644 --- a/server/drizzle/meta/_journal.json +++ b/server/drizzle/meta/_journal.json @@ -568,6 +568,13 @@ "when": 1793482370383, "tag": "0080_lazy_iron_fist", "breakpoints": true + }, + { + "idx": 81, + "version": "6", + "when": 1793564076431, + "tag": "0081_powerful_thing", + "breakpoints": true } ] } \ No newline at end of file diff --git a/server/src/app.ts b/server/src/app.ts index a5829d4..ba33aa4 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -72,6 +72,7 @@ import { fragnetRouter } from "./routes/fragnet.js"; import { arrRouter } from "./routes/arr.js"; import { wallRouter } from "./routes/wall.js"; import { adguardRouter } from "./routes/adguard.js"; +import { technitiumRouter } from "./routes/technitium.js"; import { grafanaRouter } from "./routes/grafana.js"; import { versionsRouter } from "./routes/versions.js"; import { portPresetsRouter } from "./routes/portPresets.js"; @@ -225,6 +226,7 @@ export function createApp() { app.use("/api/arr", arrRouter); app.use("/api/wall", wallRouter); app.use("/api/adguard", adguardRouter); + app.use("/api/technitium", technitiumRouter); app.use("/api/grafana", grafanaRouter); app.use("/api/versions", versionsRouter); app.use("/api/port-presets", portPresetsRouter); diff --git a/server/src/db/schema.ts b/server/src/db/schema.ts index 933a295..5a71961 100644 --- a/server/src/db/schema.ts +++ b/server/src/db/schema.ts @@ -571,6 +571,7 @@ export const integrationTypes = [ "radarr", "prowlarr", "adguard", + "technitium", "grafana", "lidarr", "readarr", @@ -1382,6 +1383,29 @@ export const adguardState = sqliteTable("adguard_state", { updatedAt: text("updated_at").notNull(), // ISO }); +// ─── Technitium DNS Server ────────────────────────────────────────────────── + +// How a Technitium DNS Server (an integration of type "technitium") is right now, one row each, replaced at every read: its version and when it started, whether blocking is on, its settings that +// matter (block lists and when they are next updated, the cache size, recursion), the statistics of the last day, the health of its zones, its DHCP leases and the result of a real DNS question +// put to it — plus since when blocking has been off and the question unanswered, which only this app can know. A column that is null could not be read. Read by services/technitiumSync.ts. +export const technitiumState = sqliteTable("technitium_state", { + integrationId: integer("integration_id") + .primaryKey() + .references(() => integrations.id, { onDelete: "cascade" }), + version: text("version"), + startedAt: text("started_at"), // ISO: when the DNS server last started; null when it did not say + dnsPort: integer("dns_port").notNull().default(53), + blockingEnabled: integer("blocking_enabled", { mode: "boolean" }).notNull().default(true), + blockingOffSince: text("blocking_off_since"), // ISO: the first read that showed blocking off; null while it is on + settings: text("settings").notNull(), // JSON: { blockLists: { count, intervalHours, nextUpdate }, cacheMaximumEntries, recursion, dnssecValidation } + stats: text("stats"), // JSON: the last day's queries and how they ended, cache and zone counts, top clients and names; null: could not be read + zones: text("zones"), // JSON: { total, disabled, issues: [{ name, problem }] }; null: could not be read + dhcp: text("dhcp"), // JSON: { scopes, enabledScopes, leases }; null: no DHCP server, or could not be read + probe: text("probe"), // JSON: the DNS question — { ok, ms, error, name, host } + probeFailSince: text("probe_fail_since"), // ISO: the first read in which the question went unanswered; null while it is answered + updatedAt: text("updated_at").notNull(), // ISO +}); + // ─── Grafana ──────────────────────────────────────────────────────────────── // How a Grafana (an integration of type "grafana") is right now, one row each, replaced at every read: the alert rules that are firing, pending or cannot be evaluated (and how many there are), and diff --git a/server/src/index.ts b/server/src/index.ts index 6c0f6f9..ae86959 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -43,6 +43,7 @@ import { initSpeedtestSync } from "./services/speedtestSync.js"; import { initFragnetSync } from "./services/fragnetSync.js"; import { initArrSync } from "./services/arrSync.js"; import { initAdguardSync } from "./services/adguardSync.js"; +import { initTechnitiumSync } from "./services/technitiumSync.js"; import { initGrafanaSync } from "./services/grafanaSync.js"; import { initVersionCheck } from "./services/appVersions.js"; import { backfillMetricRollups } from "./services/serverMetrics.js"; @@ -109,6 +110,7 @@ initSpeedtestSync(); initFragnetSync(); initArrSync(); initAdguardSync(); +initTechnitiumSync(); initGrafanaSync(); initVersionCheck(); // 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). diff --git a/server/src/integrations/fieldSchemas.ts b/server/src/integrations/fieldSchemas.ts index b8c76ff..e25f0df 100644 --- a/server/src/integrations/fieldSchemas.ts +++ b/server/src/integrations/fieldSchemas.ts @@ -147,6 +147,13 @@ export const INTEGRATION_FIELDS: Partial; + /** Null when the statistics could not be read. */ + stats: TechnitiumStats | null; + /** Null when the zones could not be listed. */ + zones: TechnitiumZones | null; + /** Null when there is no DHCP server to ask, or it could not be read. */ + dhcp: TechnitiumDhcp | null; + /** The real DNS question: whether it was answered, how fast, and about what. */ + probe: ProbeResult & { name: string; host: string }; +} + +export interface TechnitiumAdapter { + ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }>; + read(): Promise; +} + +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); +/** A moment as Technitium writes it (up to seven fractional digits, which Date.parse does not always take) as ISO; null for none, or for the year 1 it writes for "never". */ +const isoOf = (v: unknown): string | null => { + const s = str(v); + if (!s) return null; + const t = Date.parse(s.replace(/(\.\d{3})\d+/, "$1")); + return Number.isFinite(t) && t > Date.UTC(2000, 0, 1) ? new Date(t).toISOString() : null; +}; +const percent = (part: number, whole: number): number | null => (whole > 0 ? Math.round((part / whole) * 1000) / 10 : null); + +/** Pure: `/api/settings/get`'s answer. */ +export function parseSettings(raw: unknown): TechnitiumSettings { + const s = obj(raw); + const port = arr(s.dnsServerLocalEndPoints) + .map((e) => (typeof e === "string" ? /:(\d{1,5})$/.exec(e.trim()) : null)) + .find((m) => m !== null); + const interval = num(s.blockListUpdateIntervalHours); + return { + version: str(s.version), + startedAt: isoOf(s.uptimestamp), + dnsPort: port ? Number(port[1]) : 53, + blockingEnabled: s.enableBlocking !== false, + blockLists: { count: arr(s.blockListUrls).filter((u) => str(u) !== null).length, intervalHours: interval !== null && interval > 0 ? interval : null, nextUpdate: isoOf(s.blockListNextUpdatedOn) }, + cacheMaximumEntries: num(s.cacheMaximumEntries), + recursion: str(s.recursion), + dnssecValidation: typeof s.dnssecValidation === "boolean" ? s.dnssecValidation : null, + }; +} + +/** Pure: the clients or names asked about most — `[{ name, hits }]`; a client may carry the name its address resolves to (`domain`). */ +export function parseTop(raw: unknown, limit = 10): TechnitiumCounted[] { + const out: TechnitiumCounted[] = []; + for (const item of arr(raw)) { + const i = obj(item); + const name = str(i.name); + const hits = num(i.hits); + if (name === null || hits === null) continue; + const domain = str(i.domain); + out.push({ name: domain && domain !== name ? `${name} (${domain})` : name, count: hits }); + } + return out.sort((a, b) => b.count - a.count).slice(0, limit); +} + +/** Pure: `/api/dashboard/stats/get`'s `response`. No query count is not zero queries: it is "could not be read". */ +export function parseStats(raw: unknown, period = "LastDay"): TechnitiumStats | null { + const r = obj(raw); + const s = obj(r.stats); + const queries = num(s.totalQueries); + if (queries === null) return null; + const n = (k: string) => num(s[k]) ?? 0; + return { + period, + queries, + noError: n("totalNoError"), + serverFailure: n("totalServerFailure"), + nxDomain: n("totalNxDomain"), + refused: n("totalRefused"), + authoritative: n("totalAuthoritative"), + recursive: n("totalRecursive"), + cached: n("totalCached"), + blocked: n("totalBlocked"), + dropped: n("totalDropped"), + clients: n("totalClients"), + zones: num(s.zones), + cachedEntries: num(s.cachedEntries), + allowedZones: num(s.allowedZones), + blockedZones: num(s.blockedZones), + allowListZones: num(s.allowListZones), + blockListZones: num(s.blockListZones), + blockedPercent: percent(n("totalBlocked"), queries), + cachedPercent: percent(n("totalCached"), queries), + failurePercent: percent(n("totalServerFailure"), queries), + topClients: parseTop(r.topClients), + topDomains: parseTop(r.topDomains), + topBlocked: parseTop(r.topBlockedDomains), + }; +} + +/** Pure: `/api/zones/list`'s `response`. Internal zones are the server's own; a disabled zone is not judged. A secondary zone that has expired no longer answers; one that cannot sync is going stale. */ +export function parseZones(raw: unknown): TechnitiumZones | null { + const r = obj(raw); + if (!Array.isArray(r.zones)) return null; + const zones = r.zones.map(obj).filter((z) => str(z.name) !== null && z.internal !== true); + const issues: TechnitiumZoneIssue[] = []; + for (const z of zones) { + if (z.disabled === true) continue; + if (z.isExpired === true) issues.push({ name: str(z.name)!, problem: "expired" }); + else if (z.syncFailed === true) issues.push({ name: str(z.name)!, problem: "sync failed" }); + } + return { total: zones.length, disabled: zones.filter((z) => z.disabled === true).length, issues }; +} + +/** Pure: the DHCP scopes (`/api/dhcp/scopes/list`) and how many leases there are (`/api/dhcp/leases/list`, null when not asked). Null when the scopes are not a list. */ +export function parseDhcp(scopesRaw: unknown, leasesRaw: unknown | null): TechnitiumDhcp | null { + const s = obj(scopesRaw); + if (!Array.isArray(s.scopes)) return null; + return { scopes: s.scopes.length, enabledScopes: s.scopes.filter((x) => obj(x).enabled === true).length, leases: leasesRaw === null ? 0 : arr(obj(leasesRaw).leases).length }; +} + +export function createTechnitiumAdapter(config: TechnitiumConfig): TechnitiumAdapter { + const raw = String(config.url ?? "").trim().replace(/\/+$/, ""); + const insecure = config.insecure === true; + const headers = { Authorization: `Bearer ${config.token}`, Accept: "application/json" }; + + /** One call; what is returned is its `response` (the answer is `{ status, response }`, and a session or token that is not accepted is a `status`, not an HTTP error). */ + async function get(path: string, params: Record = {}): Promise> { + const qs = new URLSearchParams(params).toString(); + const res = await requestJson(`${raw}${path}${qs ? `?${qs}` : ""}`, { headers, insecure }); + if (res.status === 401 || res.status === 403) throw new Error(`Technitium did not accept the token (HTTP ${res.status})`); + if (res.status === 404) throw new Error("Technitium has no API at this address (HTTP 404) — check the address of its web console (port 5380 unless changed)"); + if (res.status < 200 || res.status >= 300) throw new Error(`Technitium error: HTTP ${res.status}`); + if (res.json === null) throw new Error("Technitium answered with something that isn't JSON — is the address its own?"); + const body = obj(res.json); + const status = str(body.status); + if (status === "invalid-token") throw new Error("Technitium did not accept the token — make a non-expiring API token (Administration → Sessions → Create Token); a server older than 15.0 does not take it in the header"); + if (status === "error") throw new Error(`Technitium: ${str(body.errorMessage) ?? "an error"}`); + if (status !== "ok") throw new Error(`Technitium answered with status "${status ?? "none"}"`); + return obj(body.response); + } + + const soft = async (run: () => Promise): Promise => { + try { + return await run(); + } catch { + return null; + } + }; + + function dnsHostOf(): string { + const given = str(config.dnsHost); + if (given) return given.replace(/^\[|\]$/g, ""); + try { + return new URL(raw).hostname.replace(/^\[|\]$/g, ""); + } catch { + return ""; + } + } + + async function readDhcp(): Promise { + const scopes = await get("/api/dhcp/scopes/list"); + const withoutLeases = parseDhcp(scopes, null); + if (withoutLeases === null || withoutLeases.scopes === 0) return withoutLeases; + return parseDhcp(scopes, await get("/api/dhcp/leases/list")); + } + + async function read(): Promise { + // The settings must work: they say it is there and the token is accepted. + const settings = parseSettings(await get("/api/settings/get")); + const name = str(config.probeDomain) ?? DEFAULT_PROBE_DOMAIN; + const host = dnsHostOf(); + const [stats, zones, dhcp, probe] = await Promise.all([ + soft(async () => parseStats(await get("/api/dashboard/stats/get", { type: "LastDay" }))), + soft(async () => parseZones(await get("/api/zones/list", { pageNumber: "1", zonesPerPage: "1000" }))), + soft(readDhcp), + host ? probeDns(host, settings.dnsPort, name) : Promise.resolve({ ok: false, ms: null, error: "no address to ask" } as ProbeResult), + ]); + return { + version: settings.version, + startedAt: settings.startedAt, + dnsPort: settings.dnsPort, + blockingEnabled: settings.blockingEnabled, + settings: { blockLists: settings.blockLists, cacheMaximumEntries: settings.cacheMaximumEntries, recursion: settings.recursion, dnssecValidation: settings.dnssecValidation }, + stats, + zones, + dhcp, + probe: { ...probe, name, host }, + }; + } + + async function ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }> { + const start = Date.now(); + try { + await get("/api/settings/get"); + return { ok: true, latencyMs: Date.now() - start }; + } catch (err) { + return { ok: false, error: err instanceof Error ? err.message : String(err) }; + } + } + + return withDiagLogging("technitium", { ping, read }); +} diff --git a/server/src/routes/integrations.ts b/server/src/routes/integrations.ts index 4ecfa59..bd617a3 100644 --- a/server/src/routes/integrations.ts +++ b/server/src/routes/integrations.ts @@ -43,6 +43,7 @@ import { forgetFragnet, syncFragnet } from "../services/fragnetSync.js"; import { forgetArr, syncArr } from "../services/arrSync.js"; import { ARR_KINDS } from "../integrations/arr/adapter.js"; import { forgetAdguard, syncAdguard } from "../services/adguardSync.js"; +import { forgetTechnitium, syncTechnitium } from "../services/technitiumSync.js"; import { forgetGrafana, syncGrafana } from "../services/grafanaSync.js"; import { forgetNextcloud, syncNextcloud } from "../services/nextcloudSync.js"; import { dockerVulnSyncStatuses, findingsOf, forgetDockerVulns, imageAgeDays, imagesOf, isDockerVulnFresh, syncDockerVulns } from "../services/dockerVulnSync.js"; @@ -160,6 +161,7 @@ integrationsRouter.post("/", requireRole("admin"), asyncHandler(async (req, res) if (type === "fragnet") void syncFragnet(created.id).then(() => invalidateAlertsCache()); if ((ARR_KINDS as string[]).includes(type)) void syncArr(created.id).then(() => invalidateAlertsCache()); if (type === "adguard") void syncAdguard(created.id).then(() => invalidateAlertsCache()); + if (type === "technitium") void syncTechnitium(created.id).then(() => invalidateAlertsCache()); if (type === "grafana") void syncGrafana(created.id).then(() => invalidateAlertsCache()); if (type === "nextcloud") void syncNextcloud(created.id).then(() => invalidateAlertsCache()); if (type === "dockhand") void syncDockerVulns(created.id).then(() => invalidateAlertsCache()); @@ -278,6 +280,7 @@ integrationsRouter.patch("/:id", requireRole("admin"), asyncHandler(async (req, if (updated.type === "fragnet" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncFragnet(updated.id).then(() => invalidateAlertsCache()); if ((ARR_KINDS as string[]).includes(updated.type) && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncArr(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "adguard" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncAdguard(updated.id).then(() => invalidateAlertsCache()); + if (updated.type === "technitium" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncTechnitium(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "grafana" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncGrafana(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()); @@ -403,6 +406,7 @@ integrationsRouter.delete("/:id", requireRole("admin"), asyncHandler(async (req, if (existing.type === "fragnet") await forgetFragnet(id); if ((ARR_KINDS as string[]).includes(existing.type)) await forgetArr(id); if (existing.type === "adguard") await forgetAdguard(id); + if (existing.type === "technitium") await forgetTechnitium(id); if (existing.type === "grafana") await forgetGrafana(id); if (existing.type === "nextcloud") await forgetNextcloud(id); if (existing.type === "dockhand") await forgetDockerVulns(id); diff --git a/server/src/routes/technitium.ts b/server/src/routes/technitium.ts new file mode 100644 index 0000000..4e8a238 --- /dev/null +++ b/server/src/routes/technitium.ts @@ -0,0 +1,39 @@ +import { Router } from "express"; +import { eq } from "drizzle-orm"; +import { db } from "../db/client.js"; +import { integrations, technitiumState } from "../db/schema.js"; +import { requireAuth } from "../auth/middleware.js"; +import { blockListsOverdueMs, isTechnitiumFresh, storedOf, technitiumProblems, technitiumSyncStatuses } from "../services/technitiumSync.js"; +import { asyncHandler } from "../utils/asyncHandler.js"; + +export const technitiumRouter = Router(); +technitiumRouter.use(requireAuth); + +/** Every Technitium DNS Server, how it is, from what the last reads stored: whether DNS answers, whether blocking is on, the last day's statistics, its zones and what is wrong. Everyone signed in can see it. */ +technitiumRouter.get("/", asyncHandler(async (_req, res) => { + const [rows, states, statuses] = await Promise.all([ + db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled, baseUrl: integrations.baseUrl }).from(integrations).where(eq(integrations.type, "technitium")).orderBy(integrations.name), + db.select().from(technitiumState), + technitiumSyncStatuses(), + ]); + const byId = new Map(states.map((s) => [s.integrationId, s])); + const now = Date.now(); + res.json({ + instances: rows.map((r) => { + const row = byId.get(r.id); + const state = row ? storedOf(row) : null; + const status = statuses[r.id] ?? null; + const fresh = isTechnitiumFresh(status ?? undefined, now); + return { + id: r.id, + name: r.name, + enabled: r.enabled, + url: r.baseUrl, + status, + fresh, + state: state && { ...state, blockListsOverdueMs: blockListsOverdueMs(state, now) }, + problems: state && fresh ? technitiumProblems(r.id, r.name, state, now) : [], + }; + }), + }); +})); diff --git a/server/src/services/alerts.ts b/server/src/services/alerts.ts index e1ac50f..339d636 100644 --- a/server/src/services/alerts.ts +++ b/server/src/services/alerts.ts @@ -92,6 +92,7 @@ const SOURCES: Record = { readarr: { label: "Readarr", link: "/media" }, prowlarr: { label: "Prowlarr", link: "/media" }, adguard: { label: "AdGuard Home", link: "/adguard" }, + technitium: { label: "Technitium DNS", link: "/technitium" }, versions: { label: "Versions", link: "/versions" }, grafana: { label: "Grafana", link: "/grafana" }, secrets: { label: "Secrets", link: "/secrets" }, @@ -140,6 +141,8 @@ function originOfConditionKey(key: string): { type: string; id: number | null; c if (m) return { type: "versions", id: Number(m[1]), category: "updates" }; m = /^adguard-(stopped|dns|protection|filters):(\d+)/.exec(key); if (m) return { type: "adguard", id: Number(m[2]), category: m[1] === "stopped" || m[1] === "dns" ? "services" : "monitoring" }; + m = /^technitium-(dns|blocking|lists|zones):(\d+)/.exec(key); + if (m) return { type: "technitium", id: Number(m[2]), category: m[1] === "dns" || m[1] === "zones" ? "services" : "monitoring" }; m = /^grafana-(firing|rule-error|ds):(\d+):/.exec(key); if (m) return { type: "grafana", id: Number(m[2]), category: m[1] === "ds" ? "integration" : "monitoring" }; m = /^(sonarr|radarr|prowlarr|lidarr|readarr)-(health|queue|disk):(\d+)/.exec(key); @@ -298,7 +301,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|sonarr|radarr|prowlarr|lidarr|readarr|adguard|grafana):(\d+)(?::(.+))?$/.exec(h); + const m = /^(proxmox|synology|unifi|ups|dockhand|jellyfin|authentik|prometheus|immich|paperless|nextcloud|netbox|n8n|hetzner|speedtest|fragnet|sonarr|radarr|prowlarr|lidarr|readarr|adguard|technitium|grafana):(\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] === "images" ? " (age of the images)" : m[3] ? ` (node ${m[3]})` : ""}`, "couldn't be read — see the Diagnostic Log", "Server and storage health"); diff --git a/server/src/services/healthMonitor.ts b/server/src/services/healthMonitor.ts index 5de42fd..e0b063e 100644 --- a/server/src/services/healthMonitor.ts +++ b/server/src/services/healthMonitor.ts @@ -1,6 +1,6 @@ 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 , arrState , adguardState , grafanaState } from "../db/schema.js"; +import { technitiumState, authentikState, n8nState, netboxState, nextcloudState, paperlessState, immichState, prometheusState, integrations, jellyfinState, networkDevices, serverPorts, servers, upsState , dockhandVulnerabilities , hetznerState , fragnetState , arrState , adguardState , grafanaState } 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"; @@ -36,6 +36,7 @@ import { hetznerProblems, hetznerSyncStatuses, imagesOf as hetznerImagesOf, load import { ARR_KINDS, type ArrKind } from "../integrations/arr/adapter.js"; import { versionProblems, versionRows, type VersionProblem } from "./appVersions.js"; import { adguardProblems, adguardSyncStatuses, isAdguardFresh, storedOf as adguardStoredOf, type AdguardProblem } from "./adguardSync.js"; +import { isTechnitiumFresh, storedOf as technitiumStoredOf, technitiumProblems, technitiumSyncStatuses, type TechnitiumProblem } from "./technitiumSync.js"; import { grafanaProblems, grafanaSyncStatuses, isGrafanaFresh, storedOf as grafanaStoredOf, type GrafanaProblem } from "./grafanaSync.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"; @@ -141,6 +142,8 @@ export interface HealthSnapshot { arr?: { integrationId: number; kind: ArrKind; problems: ArrProblem[] }[]; /** What is wrong with each AdGuard Home (DNS not running or not answering, protection left off, filter lists not updating), only while that reading is recent (services/adguardSync.ts). */ adguard?: { integrationId: number; problems: AdguardProblem[] }[]; + /** What is wrong with each Technitium DNS Server (DNS not answering, blocking left off, block lists not updating, zones expired or not syncing), only while that reading is recent (services/technitiumSync.ts). */ + technitium?: { integrationId: number; problems: TechnitiumProblem[] }[]; /** Applications a newer release of which has been out for the number of days set (services/appVersions.ts), only while the lookup of releases is on. */ versions?: VersionProblem[]; /** What is wrong with each Grafana (rules firing or failing, data sources failing their check), only while that reading is recent (services/grafanaSync.ts). */ @@ -291,6 +294,7 @@ export function evaluateHealth(snapshot: HealthSnapshot, thresholds: Thresholds, // AdGuard Home and Grafana. for (const a of snapshot.adguard ?? []) for (const p of a.problems) out.push({ key: p.key, source: `adguard:${a.integrationId}`, message: p.message, severity: p.severity }); + for (const t of snapshot.technitium ?? []) for (const p of t.problems) out.push({ key: p.key, source: `technitium:${t.integrationId}`, message: p.message, severity: p.severity }); for (const g of snapshot.grafana ?? []) for (const p of g.problems) out.push({ key: p.key, source: `grafana:${g.integrationId}`, message: p.message, severity: p.severity }); // Sonarr, Radarr and Prowlarr: what they say is wrong, downloads that are stuck, disks nearly full. @@ -628,6 +632,24 @@ export async function collectSnapshot(): Promise<{ snapshot: HealthSnapshot; hel console.error("[health] couldn't judge AdGuard Home:", err instanceof Error ? err.message : err); } + // Technitium DNS Server: read by its own pass every two minutes; what is judged is what that pass stored, and only while it is recent. + try { + const rowsT = await db.select({ id: integrations.id, name: integrations.name }).from(integrations).where(and(eq(integrations.type, "technitium"), eq(integrations.enabled, true))); + if (rowsT.length > 0) { + const statuses = await technitiumSyncStatuses(); + for (const r of rowsT) { + const [state] = await db.select().from(technitiumState).where(eq(technitiumState.integrationId, r.id)).limit(1); + if (!state || !isTechnitiumFresh(statuses[r.id], Date.now())) { + held.add(`technitium:${r.id}`); + continue; + } + (snapshot.technitium ??= []).push({ integrationId: r.id, problems: technitiumProblems(r.id, r.name, technitiumStoredOf(state), Date.now()) }); + } + } + } catch (err) { + console.error("[health] couldn't judge Technitium DNS Server:", err instanceof Error ? err.message : err); + } + // Grafana: read by its own pass every five minutes; what is judged is what that pass stored, and only while it is recent. try { const rowsR = await db.select({ id: integrations.id, name: integrations.name }).from(integrations).where(and(eq(integrations.type, "grafana"), eq(integrations.enabled, true))); diff --git a/server/src/services/integrationGroups.ts b/server/src/services/integrationGroups.ts index 95fe888..aaa22cb 100644 --- a/server/src/services/integrationGroups.ts +++ b/server/src/services/integrationGroups.ts @@ -6,7 +6,7 @@ export const INTEGRATION_GROUPS: { id: string; label: string; types: string[] }[ { id: "infrastructure", label: "Infrastructure", types: ["proxmox", "synology", "dockhand", "hetzner", "fragnet", "tailscale"] }, { id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "lidarr", "readarr", "prowlarr", "immich", "paperless", "nextcloud", "authentik"] }, { id: "backups", label: "Backups", types: ["pbs"] }, - { id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard"] }, + { id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard", "technitium"] }, { id: "monitoring", label: "Monitoring", types: ["uptimekuma", "prometheus", "grafana", "ups", "speedtest"] }, { id: "automation", label: "Automation", types: ["semaphore", "gitea", "osticket", "n8n"] }, ]; diff --git a/server/src/services/maintenance.ts b/server/src/services/maintenance.ts index 33ad1eb..17e3e71 100644 --- a/server/src/services/maintenance.ts +++ b/server/src/services/maintenance.ts @@ -49,6 +49,8 @@ export function subjectOfConditionKey(key: string): string | null { if (m) return `integration:${m[1]}`; m = /^adguard-(?:stopped|dns|protection|filters):(\d+)/.exec(key); if (m) return `integration:${m[1]}`; + m = /^technitium-(?:dns|blocking|lists|zones):(\d+)/.exec(key); + if (m) return `integration:${m[1]}`; m = /^grafana-(?:firing|rule-error|ds):(\d+):/.exec(key); if (m) return `integration:${m[1]}`; m = /^netbox-(?:workers):(\d+)/.exec(key); diff --git a/server/src/services/metrics.ts b/server/src/services/metrics.ts index 1ce1c15..ccc7580 100644 --- a/server/src/services/metrics.ts +++ b/server/src/services/metrics.ts @@ -5,7 +5,7 @@ */ 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, arrState, adguardState, grafanaState } from "../db/schema.js"; +import { technitiumState, assets, endpointChecks, heartbeats, integrations, maintenanceWindows, secrets, servers, upsState, jellyfinState, authentikState, immichState, paperlessState, nextcloudState, netboxState, n8nState, dockhandVulnerabilities, hetznerState, fragnetState, arrState, adguardState, grafanaState } from "../db/schema.js"; import { isUpsFresh, upsSyncStatuses } from "./upsSync.js"; import { levelStatuses } from "./serviceLevels.js"; import { backupState, listAll as listDuplicati } from "./duplicati.js"; @@ -17,6 +17,7 @@ import { costOf as hetznerCostOf, hetznerSyncStatuses, isHetznerFresh, serversOf import { ARR_KINDS } from "../integrations/arr/adapter.js"; import { versionRows as appVersionRows } from "./appVersions.js"; import { adguardSyncStatuses, isAdguardFresh, storedOf as adguardStoredOf } from "./adguardSync.js"; +import { blockListsOverdueMs, isTechnitiumFresh, storedOf as technitiumStoredOf, technitiumSyncStatuses } from "./technitiumSync.js"; import { grafanaSyncStatuses, isGrafanaFresh, storedOf as grafanaStoredOf } from "./grafanaSync.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"; @@ -115,6 +116,40 @@ async function addVersionMetrics(out: Exposition) { } } +/** Each Technitium DNS Server, for /metrics: whether the test question was answered and how fast, whether blocking is on, how long it has run, the last day's queries and how they ended, the cache, the zones with a problem and the DHCP leases. Only while the reading is recent. */ +async function addTechnitiumMetrics(out: Exposition, now: Date) { + const statuses = await technitiumSyncStatuses(); + const rows = new Map((await db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "technitium"))).map((r) => [r.id, r])); + for (const s of await db.select().from(technitiumState)) { + const row = rows.get(s.integrationId); + if (!row || !row.enabled || !isTechnitiumFresh(statuses[s.integrationId], now.getTime())) continue; + const state = technitiumStoredOf(s); + const labels = { name: row.name }; + out.add("homelab_technitium_blocking_enabled", "gauge", "1 if Technitium's blocking is switched on, else 0.", state.blockingEnabled ? 1 : 0, labels); + if (state.startedAt !== null) out.add("homelab_technitium_uptime_seconds", "gauge", "How long the Technitium DNS server has been running, in seconds.", Math.max(0, (now.getTime() - Date.parse(state.startedAt)) / 1000), labels); + if (state.probe) { + out.add("homelab_technitium_dns_up", "gauge", "1 if Technitium's DNS server answered a test question, else 0.", state.probe.ok ? 1 : 0, labels); + if (state.probe.ok && state.probe.ms !== null) out.add("homelab_technitium_dns_probe_seconds", "gauge", "How long Technitium's DNS server took to answer a test question, in seconds.", state.probe.ms / 1000, labels); + } + const overdue = blockListsOverdueMs(state, now.getTime()); + if (state.settings.blockLists.count > 0) out.add("homelab_technitium_block_lists_overdue", "gauge", "1 if the block lists were due for an update more than six hours ago, else 0.", overdue !== null ? 1 : 0, labels); + if (state.stats) { + out.add("homelab_technitium_queries", "gauge", "DNS queries Technitium answered in the last day.", state.stats.queries, labels); + out.add("homelab_technitium_blocked", "gauge", "Of them, the ones it blocked.", state.stats.blocked, labels); + out.add("homelab_technitium_cached", "gauge", "Of them, the ones answered from its cache.", state.stats.cached, labels); + out.add("homelab_technitium_recursive", "gauge", "Of them, the ones it had to resolve itself.", state.stats.recursive, labels); + out.add("homelab_technitium_server_failures", "gauge", "Of them, the ones that ended in a server failure.", state.stats.serverFailure, labels); + out.add("homelab_technitium_clients", "gauge", "Different clients that asked in the last day.", state.stats.clients, labels); + if (state.stats.cachedEntries !== null) out.add("homelab_technitium_cache_entries", "gauge", "Entries in Technitium's DNS cache now.", state.stats.cachedEntries, labels); + } + if (state.zones) { + out.add("homelab_technitium_zones", "gauge", "Zones Technitium holds (its own internal ones not counted).", state.zones.total, labels); + out.add("homelab_technitium_zone_problems", "gauge", "Zones that have expired or cannot sync.", state.zones.issues.length, labels); + } + if (state.dhcp) out.add("homelab_technitium_dhcp_leases", "gauge", "DHCP leases Technitium holds.", state.dhcp.leases, labels); + } +} + /** Each AdGuard Home, for /metrics: whether its DNS server runs and protects, whether the test question was answered and how fast, and what it has done over its statistics period. Only while the reading is recent. */ async function addAdguardMetrics(out: Exposition, now: Date) { const statuses = await adguardSyncStatuses(); @@ -552,6 +587,7 @@ export async function buildMetrics(now: Date = new Date()): Promise { await addFragnetMetrics(out, now); await addArrMetrics(out, now); await addAdguardMetrics(out, now); + await addTechnitiumMetrics(out, now); await addVersionMetrics(out); await addGrafanaMetrics(out, now); await addHeartbeatMetrics(out, now); diff --git a/server/src/services/technitiumSync.ts b/server/src/services/technitiumSync.ts new file mode 100644 index 0000000..ca7c05f --- /dev/null +++ b/server/src/services/technitiumSync.ts @@ -0,0 +1,223 @@ +/** + * Keeps what Technitium DNS Server says up to date: every two minutes each Technitium integration is read — its version and when it started, whether blocking is on, its block lists, the + * statistics of the last day, the health of its zones, its DHCP leases — and one real DNS question is put to its DNS server; the state is stored. Pages and alerts are built from what is + * stored. (Two minutes, not five: DNS is what everything else leans on.) + * + * What is raised: **DNS is not answering** — the test question went unanswered, or was answered with an error, in every read for ten minutes (critical; one lost packet is not an outage); + * **blocking is switched off** for an hour or more while block lists are set up (someone paused it and forgot: warning); **the block lists are overdue** — their next update was due more than + * six hours ago (warning); **a zone has a problem** — a secondary zone that has expired no longer answers (critical), one that cannot sync is going stale (warning). "Since when" is what this + * app saw: the time of the first read that showed it. + */ +import { and, eq } from "drizzle-orm"; +import { db } from "../db/client.js"; +import { integrations, technitiumState } from "../db/schema.js"; +import { createTechnitiumAdapter, type TechnitiumDhcp, type TechnitiumRead, type TechnitiumStats, type TechnitiumZones } from "../integrations/technitium/adapter.js"; +import type { ProbeResult } from "../integrations/adguard/dnsProbe.js"; +import { loadIntegrationConfig } from "../integrations/loadIntegration.js"; +import { getInternalFlag, setInternalFlag } from "./settingsStore.js"; + +export const SYNC_INTERVAL_MS = 2 * 60_000; +/** After this long without a good read, what is stored is no longer believed. */ +export const STALE_AFTER_MS = 10 * 60_000; +const STATUS_FLAG = "technitiumSync"; + +const MIN = 60_000; +const HOUR = 60 * MIN; +/** DNS that has not answered in any read for this long is down. */ +export const DNS_FAIL_AFTER_MS = 10 * MIN; +/** Blocking off for this long is forgotten, not paused. */ +export const BLOCKING_OFF_AFTER_MS = HOUR; +/** Block lists whose next update was due this long ago have stopped updating (Technitium tries again soon after a failed one). */ +export const LISTS_OVERDUE_MS = 6 * HOUR; + +export interface TechnitiumSyncStatus { + /** 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 technitiumSyncStatuses(): Promise> { + return Object.fromEntries(Object.entries(await readStatuses()).map(([k, v]) => [Number(k), v])); +} + +export const isTechnitiumFresh = (status: TechnitiumSyncStatus | undefined, nowMs: number) => !!status && status.ok && nowMs - Date.parse(status.at) <= STALE_AFTER_MS; + +export type StateRow = typeof technitiumState.$inferSelect; + +/** What is stored of one Technitium, as the read gave it, plus what the app has seen between reads. */ +export interface StoredTechnitium { + version: string | null; + startedAt: string | null; + dnsPort: number; + blockingEnabled: boolean; + /** When the first read that showed blocking off was made; null while it is on. */ + blockingOffSince: string | null; + settings: TechnitiumRead["settings"]; + stats: TechnitiumStats | null; + zones: TechnitiumZones | null; + dhcp: TechnitiumDhcp | null; + probe: (ProbeResult & { name: string; host: string }) | null; + /** When the first read that showed the DNS test failing was made; null while it works. */ + probeFailSince: string | null; + updatedAt: string; +} + +function parse(stored: string | null): T | null { + if (stored === null) return null; + try { + return JSON.parse(stored) as T; + } catch { + return null; + } +} + +const NO_SETTINGS: TechnitiumRead["settings"] = { blockLists: { count: 0, intervalHours: null, nextUpdate: null }, cacheMaximumEntries: null, recursion: null, dnssecValidation: null }; + +export const storedOf = (row: StateRow): StoredTechnitium => ({ + version: row.version, + startedAt: row.startedAt, + dnsPort: row.dnsPort, + blockingEnabled: row.blockingEnabled, + blockingOffSince: row.blockingOffSince, + settings: parse(row.settings) ?? NO_SETTINGS, + stats: parse(row.stats), + zones: parse(row.zones), + dhcp: parse(row.dhcp), + probe: parse(row.probe), + probeFailSince: row.probeFailSince, + updatedAt: row.updatedAt, +}); + +/** Pure: what the app has seen between reads, carried from the last read. A thing first seen wrong starts its clock now. */ +export function carrySince(read: Pick, previous: Pick | null, now: Date): { blockingOffSince: string | null; probeFailSince: string | null } { + const at = now.toISOString(); + return { + blockingOffSince: read.blockingEnabled ? null : (previous?.blockingOffSince ?? at), + probeFailSince: read.probe.ok ? null : (previous?.probeFailSince ?? at), + }; +} + +/** Writes down one read, replacing the last (and carrying what was seen between reads). */ +export async function storeRead(integrationId: number, r: TechnitiumRead, now: Date = new Date()): Promise { + const [previous] = await db.select().from(technitiumState).where(eq(technitiumState.integrationId, integrationId)).limit(1); + const since = carrySince(r, previous ? storedOf(previous) : null, now); + const values = { + version: r.version, + startedAt: r.startedAt, + dnsPort: r.dnsPort, + blockingEnabled: r.blockingEnabled, + blockingOffSince: since.blockingOffSince, + settings: JSON.stringify(r.settings), + stats: r.stats && JSON.stringify(r.stats), + zones: r.zones && JSON.stringify(r.zones), + dhcp: r.dhcp && JSON.stringify(r.dhcp), + probe: JSON.stringify(r.probe), + probeFailSince: since.probeFailSince, + updatedAt: now.toISOString(), + }; + await db.insert(technitiumState).values({ integrationId, ...values }).onConflictDoUpdate({ target: technitiumState.integrationId, set: values }); +} + +/** Reads one Technitium and stores it. Never throws: how it went is the answer, and what was stored is left alone when it failed. */ +export async function syncTechnitium(integrationId: number, now: Date = new Date(), read?: (config: Record) => Promise): Promise { + let status: TechnitiumSyncStatus; + try { + const loaded = await loadIntegrationConfig(integrationId); + if (!loaded || loaded.integration.type !== "technitium") throw new Error("not a Technitium integration"); + const result = await (read ? read(loaded.config) : createTechnitiumAdapter(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(`[technitium] 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("[technitium] couldn't record the result:", err); + } + return status; +} + +export async function syncAllTechnitium(now: Date = new Date()): Promise> { + const rows = await db.select({ id: integrations.id }).from(integrations).where(and(eq(integrations.type, "technitium"), eq(integrations.enabled, true))); + const out: Record = {}; + for (const r of rows) out[r.id] = await syncTechnitium(r.id, now); + return out; +} + +export async function forgetTechnitium(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 TechnitiumProblem { + key: string; + message: string; + severity: "warning" | "critical"; +} + +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: how long ago the block lists were due for an update, when that is more than the grace; null when they are not overdue, or none are set up, or no time was said. */ +export function blockListsOverdueMs(s: Pick, nowMs: number): number | null { + const l = s.settings.blockLists; + if (l.count === 0 || l.nextUpdate === null) return null; + const over = nowMs - Date.parse(l.nextUpdate); + return over > LISTS_OVERDUE_MS ? over : null; +} + +/** Pure: what is wrong with one Technitium, from what is stored for it. */ +export function technitiumProblems(id: number, name: string, s: StoredTechnitium, nowMs: number): TechnitiumProblem[] { + const out: TechnitiumProblem[] = []; + if (s.probe && !s.probe.ok && s.probeFailSince !== null && nowMs - Date.parse(s.probeFailSince) >= DNS_FAIL_AFTER_MS) { + out.push({ key: `technitium-dns:${id}`, severity: "critical", message: `${name}: DNS has not answered a question about ${s.probe.name} for ${ago(nowMs - Date.parse(s.probeFailSince))} (asked ${s.probe.host}:${s.dnsPort}) — ${s.probe.error ?? "no answer"}` }); + } + if (!s.blockingEnabled && s.settings.blockLists.count > 0 && s.blockingOffSince !== null && nowMs - Date.parse(s.blockingOffSince) >= BLOCKING_OFF_AFTER_MS) { + out.push({ key: `technitium-blocking:${id}`, severity: "warning", message: `${name}: Technitium's blocking has been switched off for ${ago(nowMs - Date.parse(s.blockingOffSince))} — nothing is being blocked` }); + } + const overdue = blockListsOverdueMs(s, nowMs); + if (overdue !== null) { + out.push({ key: `technitium-lists:${id}`, severity: "warning", message: `${name}: the block lists were due for an update ${ago(overdue)} ago and have not been updated` }); + } + const issues = s.zones?.issues ?? []; + if (issues.length > 0) { + const expired = issues.some((i) => i.problem === "expired"); + const names = issues.slice(0, 3).map((i) => `${i.name} (${i.problem})`); + out.push({ + key: `technitium-zones:${id}`, + severity: expired ? "critical" : "warning", + message: `${name}: ${plural(issues.length, "zone")} ${issues.length === 1 ? "has" : "have"} a problem — ${names.join(", ")}${issues.length > 3 ? ` and ${issues.length - 3} more` : ""}${expired ? " (an expired secondary zone no longer answers)" : ""}`, + }); + } + return out; +} + +let timer: ReturnType | null = null; + +export function initTechnitiumSync(): void { + if (timer) return; + const pass = () => void syncAllTechnitium().catch((err) => console.error("[technitium] pass failed:", err)); + timer = setInterval(pass, SYNC_INTERVAL_MS); + setTimeout(pass, 40_000); + console.log(`[technitium] reading Technitium DNS Server every ${SYNC_INTERVAL_MS / 60000} minutes`); +} diff --git a/server/test/technitium.test.ts b/server/test/technitium.test.ts new file mode 100644 index 0000000..aca09b3 --- /dev/null +++ b/server/test/technitium.test.ts @@ -0,0 +1,531 @@ +/** + * Technitium DNS Server (statistics, zones, block lists, DHCP and a real DNS question over UDP): reading what its API says, what is stored and carried between reads, what is wrong, the + * health pass, the alerts, the page's route and /metrics. + * + * Run with: npm test --workspace server + */ +import { test, describe, before, after } from "node:test"; +import assert from "node:assert/strict"; +import * as dgram from "node:dgram"; +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-technitium-")); +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, technitiumState } = await import("../src/db/schema.js"); +const { runMigrations } = await import("../src/db/migrate.js"); +const { INTEGRATION_FIELDS } = await import("../src/integrations/fieldSchemas.js"); +const tn = await import("../src/integrations/technitium/adapter.js"); +const ts = await import("../src/services/technitiumSync.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 { technitiumRouter } = await import("../src/routes/technitium.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 DAY = 24 * HOUR; +const iso = (ms: number) => new Date(ms).toISOString(); + +/** A DNS server that answers with the rcode it is told to (or not at all), once per question. */ +async function fakeDns(behaviour: () => { rcode?: number; silent?: boolean }) { + const socket = dgram.createSocket("udp4"); + const questions: string[] = []; + socket.on("message", (msg, rinfo) => { + const b = behaviour(); + let i = 12; + const labels: string[] = []; + while (msg[i] !== 0 && i < msg.length) { + labels.push(msg.subarray(i + 1, i + 1 + msg[i]).toString("ascii")); + i += msg[i] + 1; + } + questions.push(labels.join(".")); + if (b.silent) return; + const reply = Buffer.from(msg); + reply.writeUInt16BE(0x8180 | (b.rcode ?? 0), 2); + reply.writeUInt16BE(b.rcode ? 0 : 1, 6); + socket.send(reply, rinfo.port, rinfo.address); + }); + await new Promise((resolve) => socket.bind(0, "127.0.0.1", resolve)); + return { port: socket.address().port, questions, close: () => socket.close() }; +} + +describe("what Technitium's API says", () => { + test("the settings: version, when it started (seven fractional digits are fine), the DNS port from its endpoints, blocking, the block lists and when they are next updated", () => { + const s = tn.parseSettings({ + version: "15.5", + uptimestamp: "2026-10-20T08:00:00.1234567Z", + dnsServerLocalEndPoints: ["[::]:5353", "0.0.0.0:5353"], + enableBlocking: false, + blockListUrls: ["https://a.example/list", " ", "https://b.example/list"], + blockListUpdateIntervalHours: 24, + blockListNextUpdatedOn: "2026-10-21T08:00:00.0000000Z", + cacheMaximumEntries: 10000, + recursion: "AllowOnlyForPrivateNetworks", + dnssecValidation: true, + }); + assert.deepEqual(s, { + version: "15.5", + startedAt: "2026-10-20T08:00:00.123Z", + dnsPort: 5353, + blockingEnabled: false, + blockLists: { count: 2, intervalHours: 24, nextUpdate: "2026-10-21T08:00:00.000Z" }, + cacheMaximumEntries: 10000, + recursion: "AllowOnlyForPrivateNetworks", + dnssecValidation: true, + }); + }); + + test("a setting that is missing is what it should be: port 53, blocking on, nothing set up, nothing known", () => { + assert.deepEqual(tn.parseSettings({}), { version: null, startedAt: null, dnsPort: 53, blockingEnabled: true, blockLists: { count: 0, intervalHours: null, nextUpdate: null }, cacheMaximumEntries: null, recursion: null, dnssecValidation: null }); + assert.equal(tn.parseSettings({ uptimestamp: "0001-01-01T00:00:00Z", blockListNextUpdatedOn: "0001-01-01T00:00:00Z" }).startedAt, null, "the year 1 is never a time"); + assert.equal(tn.parseSettings({ blockListUpdateIntervalHours: 0 }).blockLists.intervalHours, null); + }); + + test("the clients and names asked about most: biggest first, a client with the name its address resolves to is both", () => { + const top = tn.parseTop([{ name: "ads.example", hits: 5 }, { name: "192.168.1.5", domain: "laptop.lan", hits: 40 }, { name: "x", hits: "many" }, { hits: 3 }, { name: "same", domain: "same", hits: 9 }]); + assert.deepEqual(top, [{ name: "192.168.1.5 (laptop.lan)", count: 40 }, { name: "same", count: 9 }, { name: "ads.example", count: 5 }]); + assert.equal(tn.parseTop(Array.from({ length: 30 }, (_, i) => ({ name: `n${i}`, hits: i }))).length, 10); + }); + + test("the statistics: how the queries ended and what share was blocked, cached or failed; no query count is not zero queries", () => { + const s = tn.parseStats({ + stats: { totalQueries: 2000, totalNoError: 1700, totalServerFailure: 100, totalNxDomain: 150, totalRefused: 50, totalAuthoritative: 200, totalRecursive: 500, totalCached: 1000, totalBlocked: 250, totalDropped: 50, totalClients: 12, zones: 7, cachedEntries: 4321, allowedZones: 2, blockedZones: 3, allowListZones: 0, blockListZones: 90210 }, + topClients: [{ name: "10.0.0.2", hits: 700 }], + topDomains: [{ name: "example.com", hits: 90 }], + topBlockedDomains: [{ name: "ads.example", hits: 60 }], + })!; + assert.deepEqual([s.queries, s.blocked, s.blockedPercent, s.cachedPercent, s.failurePercent, s.clients, s.cachedEntries, s.blockListZones], [2000, 250, 12.5, 50, 5, 12, 4321, 90210]); + assert.deepEqual([s.topClients[0], s.topDomains[0], s.topBlocked[0]], [{ name: "10.0.0.2", count: 700 }, { name: "example.com", count: 90 }, { name: "ads.example", count: 60 }]); + assert.equal(tn.parseStats({ stats: {} }), null); + assert.equal(tn.parseStats("nonsense"), null); + assert.equal(tn.parseStats({ stats: { totalQueries: 0 } })!.blockedPercent, null, "no queries, no share"); + }); + + test("the zones: an expired secondary zone and one that cannot sync are problems; the server's own, and switched-off ones, are not", () => { + const z = tn.parseZones({ + totalZones: 6, + zones: [ + { name: "home.lan", type: "Primary" }, + { name: "lab.lan", type: "Secondary", isExpired: true, syncFailed: true }, + { name: "other.lan", type: "Secondary", syncFailed: true }, + { name: "old.lan", type: "Secondary", isExpired: true, disabled: true }, + { name: "localhost", type: "Primary", internal: true }, + { type: "Primary" }, + ], + })!; + assert.deepEqual(z, { total: 4, disabled: 1, issues: [{ name: "lab.lan", problem: "expired" }, { name: "other.lan", problem: "sync failed" }] }); + assert.equal(tn.parseZones({}), null); + }); + + test("DHCP: the scopes, which are on, and the leases; not a list of scopes is not a DHCP server", () => { + const scopes = { scopes: [{ name: "lan", enabled: true }, { name: "guest", enabled: false }] }; + assert.deepEqual(tn.parseDhcp(scopes, { leases: [{}, {}, {}] }), { scopes: 2, enabledScopes: 1, leases: 3 }); + assert.deepEqual(tn.parseDhcp(scopes, null), { scopes: 2, enabledScopes: 1, leases: 0 }); + assert.equal(tn.parseDhcp({}, null), null); + }); + + test("the token is a required secret of the integration, and the DNS test address and name are optional", () => { + const fields = INTEGRATION_FIELDS.technitium!; + const token = fields.find((f) => f.key === "token")!; + assert.deepEqual([token.secret, token.type, token.optional ?? false], [true, "password", false]); + assert.equal(fields.find((f) => f.key === "dnsHost")?.optional, true); + assert.equal(fields.find((f) => f.key === "probeDomain")?.optional, true); + }); +}); + +describe("the adapter against a Technitium that answers", () => { + let web: Server; + let url = ""; + let dns: Awaited>; + const seen: { path: string; auth: string }[] = []; + let envelope: { status: string; errorMessage?: string } = { status: "ok" }; + let failing = new Set(); + let httpStatus = 200; + let rawBody: string | null = null; + let dhcpScopes: unknown[] = [{ name: "lan", enabled: true }]; + /** The port the fake settings say the DNS server is on; the one of the answering fake DNS server unless a test points it elsewhere. */ + let endpointPort: number | null = null; + + before(async () => { + dns = await fakeDns(() => ({})); + web = createHttpServer((req, res) => { + const u = new URL(req.url ?? "", "http://x"); + seen.push({ path: u.pathname + u.search, auth: String(req.headers.authorization ?? "") }); + const send = (status: number, body: string) => { + res.writeHead(status, { "content-type": "application/json" }); + res.end(body); + }; + if (httpStatus !== 200) return send(httpStatus, ""); + if (rawBody !== null) return send(200, rawBody); + if (failing.has(u.pathname)) return send(500, "{}"); + if (envelope.status !== "ok") return send(200, JSON.stringify(envelope)); + const ok = (response: unknown) => send(200, JSON.stringify({ status: "ok", response })); + switch (u.pathname) { + case "/api/settings/get": + return ok({ version: "15.5", uptimestamp: iso(Date.now() - 3 * DAY), dnsServerLocalEndPoints: [`127.0.0.1:${endpointPort ?? dns.port}`], enableBlocking: true, blockListUrls: ["https://a.example/list"], blockListUpdateIntervalHours: 24, blockListNextUpdatedOn: iso(Date.now() + 5 * HOUR), cacheMaximumEntries: 10000, recursion: "AllowOnlyForPrivateNetworks", dnssecValidation: true }); + case "/api/dashboard/stats/get": + return ok({ stats: { totalQueries: 1000, totalBlocked: 200, totalCached: 500, totalServerFailure: 10, totalClients: 4, cachedEntries: 300, zones: 2 }, topClients: [{ name: "10.0.0.2", hits: 600 }], topDomains: [], topBlockedDomains: [] }); + case "/api/zones/list": + return ok({ totalZones: 2, zones: [{ name: "home.lan", type: "Primary" }, { name: "lab.lan", type: "Secondary", isExpired: true }] }); + case "/api/dhcp/scopes/list": + return ok({ scopes: dhcpScopes }); + case "/api/dhcp/leases/list": + return ok({ leases: [{}, {}] }); + default: + return send(404, "{}"); + } + }); + await new Promise((resolve) => web.listen(0, "127.0.0.1", resolve)); + url = `http://127.0.0.1:${(web.address() as AddressInfo).port}`; + }); + after(() => { + web.close(); + dns.close(); + }); + const adapter = (extra: Record = {}) => tn.createTechnitiumAdapter({ url: `${url}/`, token: "tok-1", ...extra } as never); + const reset = () => { + seen.length = 0; + envelope = { status: "ok" }; + failing = new Set(); + httpStatus = 200; + rawBody = null; + dhcpScopes = [{ name: "lan", enabled: true }]; + }; + + test("a read puts the token in the Authorization header, asks the five things and one DNS question, and says what each answered", async () => { + reset(); + const r = await adapter().read(); + assert.deepEqual([...new Set(seen.map((s) => s.auth))], ["Bearer tok-1"]); + assert.deepEqual(seen.map((s) => s.path).sort(), ["/api/dashboard/stats/get?type=LastDay", "/api/dhcp/leases/list", "/api/dhcp/scopes/list", "/api/settings/get", "/api/zones/list?pageNumber=1&zonesPerPage=1000"]); + assert.deepEqual([r.version, r.dnsPort, r.blockingEnabled, r.settings.blockLists.count, r.settings.cacheMaximumEntries], ["15.5", dns.port, true, 1, 10000]); + assert.deepEqual([r.stats?.queries, r.stats?.blockedPercent, r.zones?.issues, r.dhcp], [1000, 20, [{ name: "lab.lan", problem: "expired" }], { scopes: 1, enabledScopes: 1, leases: 2 }]); + assert.deepEqual([r.probe.ok, r.probe.name, r.probe.host], [true, "example.com", "127.0.0.1"]); + assert.deepEqual(dns.questions.at(-1), "example.com"); + assert.ok(Date.now() - Date.parse(r.startedAt!) > 2.9 * DAY); + }); + + test("the name asked about and the DNS address can be set; no DHCP scopes means the leases are not asked for", async () => { + reset(); + dhcpScopes = []; + const r = await adapter({ probeDomain: "internal.test", dnsHost: "127.0.0.1" }).read(); + assert.equal(dns.questions.at(-1), "internal.test"); + assert.deepEqual(r.dhcp, { scopes: 0, enabledScopes: 0, leases: 0 }); + assert.equal(seen.some((s) => s.path === "/api/dhcp/leases/list"), false); + }); + + test("what cannot be read is left out and the rest is kept: statistics, zones and DHCP are each soft; the settings are not", async () => { + reset(); + failing = new Set(["/api/dashboard/stats/get", "/api/zones/list", "/api/dhcp/scopes/list"]); + const r = await adapter().read(); + assert.deepEqual([r.stats, r.zones, r.dhcp, r.version], [null, null, null, "15.5"]); + reset(); + failing = new Set(["/api/settings/get"]); + await assert.rejects(() => adapter().read(), /HTTP 500/); + }); + + test("a token that is not accepted, an error Technitium words, an address that is not Technitium's and an answer that is not JSON are each said", async () => { + reset(); + envelope = { status: "invalid-token" }; + await assert.rejects(() => adapter().read(), /did not accept the token — make a non-expiring API token/); + envelope = { status: "error", errorMessage: "Access was denied." }; + await assert.rejects(() => adapter().read(), /Technitium: Access was denied\./); + envelope = { status: "2fa-required" }; + await assert.rejects(() => adapter().read(), /status "2fa-required"/); + reset(); + httpStatus = 404; + await assert.rejects(() => adapter().read(), /no API at this address/); + httpStatus = 403; + await assert.rejects(() => adapter().read(), /did not accept the token \(HTTP 403\)/); + reset(); + rawBody = "hello"; + await assert.rejects(() => adapter().read(), /isn't JSON/); + }); + + test("a DNS server that does not answer, or answers with a failure, is said in the read — and the read still works; \"no such name\" is an answer", async () => { + reset(); + const quiet = await fakeDns(() => ({ silent: true })); + endpointPort = quiet.port; + try { + const r = await adapter().read(); + assert.deepEqual([r.probe.ok, /no answer/.test(r.probe.error ?? ""), r.stats?.queries], [false, true, 1000]); + } finally { + quiet.close(); + } + const failing = await fakeDns(() => ({ rcode: 2 })); + endpointPort = failing.port; + try { + const r = await adapter().read(); + assert.deepEqual([r.probe.ok, /server failure/.test(r.probe.error ?? "")], [false, true]); + } finally { + failing.close(); + } + const nx = await fakeDns(() => ({ rcode: 3 })); + endpointPort = nx.port; + try { + assert.equal((await adapter().read()).probe.ok, true); + } finally { + nx.close(); + endpointPort = null; + } + }); + + test("ping asks the settings and says how long it took, or why not", async () => { + reset(); + const ok = await adapter().ping(); + assert.equal(ok.ok, true); + assert.equal(typeof ok.latencyMs, "number"); + envelope = { status: "invalid-token" }; + const bad = await adapter().ping(); + assert.deepEqual([bad.ok, /did not accept the token/.test(bad.error ?? "")], [false, true]); + }); +}); + +/** A read as the adapter gives it, for the parts that need only what it says. */ +function read(over: Partial = {}): import("../src/integrations/technitium/adapter.js").TechnitiumRead { + return { + version: "15.5", + startedAt: iso(Date.now() - 5 * DAY), + dnsPort: 53, + blockingEnabled: true, + settings: { blockLists: { count: 2, intervalHours: 24, nextUpdate: iso(Date.now() + 6 * HOUR) }, cacheMaximumEntries: 10000, recursion: "AllowOnlyForPrivateNetworks", dnssecValidation: true }, + stats: { period: "LastDay", queries: 1000, noError: 900, serverFailure: 20, nxDomain: 60, refused: 20, authoritative: 100, recursive: 300, cached: 500, blocked: 100, dropped: 0, clients: 5, zones: 3, cachedEntries: 4000, allowedZones: 0, blockedZones: 0, allowListZones: 0, blockListZones: 80000, blockedPercent: 10, cachedPercent: 50, failurePercent: 2, topClients: [{ name: "10.0.0.2", count: 500 }], topDomains: [{ name: "example.com", count: 90 }], topBlocked: [{ name: "ads.example", count: 60 }] }, + zones: { total: 3, disabled: 0, issues: [] }, + dhcp: { scopes: 1, enabledScopes: 1, leases: 12 }, + probe: { ok: true, ms: 7, error: null, name: "example.com", host: "dns.lan" }, + ...over, + }; +} + +describe("what Technitium is carried and judged by", () => { + const now = new Date("2026-11-01T12:00:00Z"); + const stored = (over: Partial = {}): import("../src/services/technitiumSync.js").StoredTechnitium => ({ + version: "15.5", + startedAt: null, + dnsPort: 53, + blockingEnabled: true, + blockingOffSince: null, + settings: read().settings, + stats: null, + zones: { total: 2, disabled: 0, issues: [] }, + dhcp: null, + probe: { ok: true, ms: 5, error: null, name: "example.com", host: "dns.lan" }, + probeFailSince: null, + updatedAt: now.toISOString(), + ...over, + }); + + test("since when: a thing first seen wrong starts its clock now, keeps it while it stays wrong, and loses it when it is right", () => { + const bad = read({ blockingEnabled: false, probe: { ok: false, ms: null, error: "no answer in 3 s", name: "example.com", host: "dns.lan" } }); + const first = ts.carrySince(bad, null, now); + assert.deepEqual(first, { blockingOffSince: now.toISOString(), probeFailSince: now.toISOString() }); + const later = ts.carrySince(bad, { blockingOffSince: iso(now.getTime() - HOUR), probeFailSince: iso(now.getTime() - 30 * MIN) }, now); + assert.deepEqual(later, { blockingOffSince: iso(now.getTime() - HOUR), probeFailSince: iso(now.getTime() - 30 * MIN) }); + assert.deepEqual(ts.carrySince(read(), { blockingOffSince: iso(now.getTime() - HOUR), probeFailSince: iso(now.getTime() - HOUR) }, now), { blockingOffSince: null, probeFailSince: null }); + }); + + const failing = (min: number) => ({ probe: { ok: false, ms: null, error: "no answer in 3 s", name: "example.com", host: "dns.lan" }, probeFailSince: iso(now.getTime() - min * MIN) }); + + test("a DNS question unanswered for ten minutes is critical; for less it is one lost packet", () => { + assert.deepEqual(ts.technitiumProblems(1, "Home DNS", stored(failing(9)), now.getTime()), []); + const [p] = ts.technitiumProblems(1, "Home DNS", stored(failing(12)), now.getTime()); + assert.deepEqual([p.key, p.severity], ["technitium-dns:1", "critical"]); + assert.match(p.message, /Home DNS: DNS has not answered a question about example\.com for 12 minutes \(asked dns\.lan:53\) — no answer in 3 s/); + }); + + test("blocking off for an hour is a warning, but only where block lists are set up; for less it is a pause", () => { + const off = (min: number, count = 2) => stored({ blockingEnabled: false, blockingOffSince: iso(now.getTime() - min * MIN), settings: { ...read().settings, blockLists: { count, intervalHours: 24, nextUpdate: null } } }); + assert.deepEqual(ts.technitiumProblems(1, "D", off(59), now.getTime()), []); + assert.deepEqual(ts.technitiumProblems(1, "D", off(61), now.getTime()).map((p) => [p.key, p.severity]), [["technitium-blocking:1", "warning"]]); + assert.deepEqual(ts.technitiumProblems(1, "D", off(600, 0), now.getTime()), [], "no block lists: off is how it is"); + }); + + test("block lists whose update was due more than six hours ago are a warning; one not yet due, one with no time said and none set up are not", () => { + const lists = (nextUpdate: string | null, count = 2) => stored({ settings: { ...read().settings, blockLists: { count, intervalHours: 24, nextUpdate } } }); + assert.equal(ts.blockListsOverdueMs(lists(iso(now.getTime() - 5 * HOUR)), now.getTime()), null); + assert.equal(ts.blockListsOverdueMs(lists(iso(now.getTime() - 10 * HOUR)), now.getTime()), 10 * HOUR); + assert.equal(ts.blockListsOverdueMs(lists(null), now.getTime()), null); + assert.equal(ts.blockListsOverdueMs(lists(iso(now.getTime() - 10 * HOUR), 0), now.getTime()), null); + const [p] = ts.technitiumProblems(1, "D", lists(iso(now.getTime() - 30 * HOUR)), now.getTime()); + assert.deepEqual([p.key, p.severity], ["technitium-lists:1", "warning"]); + assert.match(p.message, /due for an update 30 hours ago/); + }); + + test("an expired secondary zone is critical and says it no longer answers; zones that only cannot sync are a warning; each is one alert that names the first few", () => { + const sync = ts.technitiumProblems(1, "D", stored({ zones: { total: 5, disabled: 0, issues: [{ name: "a.lan", problem: "sync failed" }] } }), now.getTime()); + assert.deepEqual(sync.map((p) => [p.key, p.severity]), [["technitium-zones:1", "warning"]]); + assert.match(sync[0].message, /1 zone has a problem — a\.lan \(sync failed\)$/); + const many = ts.technitiumProblems( + 1, + "D", + stored({ zones: { total: 9, disabled: 0, issues: [{ name: "a.lan", problem: "expired" }, { name: "b.lan", problem: "sync failed" }, { name: "c.lan", problem: "sync failed" }, { name: "d.lan", problem: "sync failed" }] } }), + now.getTime(), + ); + assert.deepEqual(many.map((p) => [p.key, p.severity]), [["technitium-zones:1", "critical"]]); + assert.match(many[0].message, /4 zones have a problem — a\.lan \(expired\), b\.lan \(sync failed\), c\.lan \(sync failed\) and 1 more \(an expired secondary zone no longer answers\)/); + }); + + test("a Technitium with nothing wrong says nothing; a zones list that could not be read says nothing either", () => { + assert.deepEqual(ts.technitiumProblems(1, "D", stored(), now.getTime()), []); + assert.deepEqual(ts.technitiumProblems(1, "D", stored({ zones: null }), now.getTime()), []); + }); +}); + +describe("what Technitium has stored", () => { + let id = 0; + before(async () => { + id = (await db.insert(integrations).values({ type: "technitium", name: "Stored DNS", baseUrl: "http://stored", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + }); + const row = async () => (await db.select().from(technitiumState).where(eq(technitiumState.integrationId, id)))[0]; + after(async () => { + await ts.forgetTechnitium(id); + await db.delete(integrations).where(eq(integrations.id, id)); + }); + + test("the state is replaced at each read, carrying the clocks between them; what could not be read is stored as not read", async () => { + const t0 = new Date(); + const down = read({ blockingEnabled: false, probe: { ok: false, ms: null, error: "no answer", name: "example.com", host: "dns.lan" }, stats: null, zones: null, dhcp: null }); + await ts.storeRead(id, down, t0); + await ts.storeRead(id, down, new Date(t0.getTime() + 5 * MIN)); + const r1 = await row(); + assert.deepEqual([r1.blockingOffSince, r1.probeFailSince], [t0.toISOString(), t0.toISOString()]); + assert.deepEqual([r1.stats, r1.zones, r1.dhcp], [null, null, null]); + await ts.storeRead(id, read(), new Date(t0.getTime() + 10 * MIN)); + const r2 = await row(); + assert.deepEqual([r2.blockingOffSince, r2.probeFailSince, ts.storedOf(r2).stats?.queries], [null, null, 1000]); + }); + + test("a read that failed is said, and what was stored is left alone", async () => { + const ok = await ts.syncTechnitium(id, new Date(), async () => read({ version: "kept" })); + assert.equal(ok.ok, true); + const failed = await ts.syncTechnitium(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((await row()).version, "kept"); + assert.equal(ts.isTechnitiumFresh((await ts.technitiumSyncStatuses())[id], Date.now()), false); + }); + + test("an integration of another kind is not read", async () => { + const other = (await db.insert(integrations).values({ type: "adguard", name: "Not Technitium", baseUrl: "http://x", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + const status = await ts.syncTechnitium(other, new Date(), async () => read()); + assert.deepEqual([status.ok, status.error], [false, "not a Technitium integration"]); + await db.delete(integrations).where(eq(integrations.id, other)); + }); +}); + +describe("the health pass, the Alerts page, the page's route and /metrics", () => { + let tId = 0; + let app: Server; + let base = ""; + const statusAt = (ms: number) => setInternalFlag("technitiumSync", JSON.stringify({ [tId]: { at: new Date(ms).toISOString(), ok: true, error: null } })); + const fresh = () => statusAt(Date.now()); + const stale = () => statusAt(Date.now() - 30 * MIN); + + before(async () => { + await db.insert(users).values([{ oidcSub: "viewer", name: "Vic", role: "viewer" }]); + tId = (await db.insert(integrations).values({ type: "technitium", name: "Home DNS 2", baseUrl: "http://technitium", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + const t0 = new Date(Date.now() - 3 * HOUR); + const bad = read({ + blockingEnabled: false, + settings: { blockLists: { count: 2, intervalHours: 24, nextUpdate: iso(Date.now() - 10 * HOUR) }, cacheMaximumEntries: 10000, recursion: null, dnssecValidation: null }, + zones: { total: 3, disabled: 0, issues: [{ name: "lab.lan", problem: "expired" }] }, + probe: { ok: false, ms: null, error: "no answer in 3 s", name: "example.com", host: "dns.lan" }, + }); + await ts.storeRead(tId, bad, t0); + await ts.storeRead(tId, bad, 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/technitium", technitiumRouter); + 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/technitium`; + }); + 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 it from what is stored, and holds it when the last read is old; maintenance on the integration silences each", async () => { + let { snapshot, held } = await collectSnapshot(); + assert.deepEqual(snapshot.technitium?.map((x) => x.integrationId), [tId]); + const list = evaluateHealth(snapshot, { serverOfflineMinutes: 60, diskUsagePercent: 90 }, Date.now(), { skipServers: true }); + const mine = list.filter((x) => x.key.startsWith("technitium-")).map((x) => `${x.key}=${x.severity}`).sort(); + assert.deepEqual(mine, [`technitium-blocking:${tId}=warning`, `technitium-dns:${tId}=critical`, `technitium-lists:${tId}=warning`, `technitium-zones:${tId}=critical`].sort()); + assert.equal(list.find((x) => x.key === `technitium-dns:${tId}`)!.source, `technitium:${tId}`); + for (const k of ["dns", "blocking", "lists", "zones"]) assert.equal(subjectOfConditionKey(`technitium-${k}:${tId}`), `integration:${tId}`, k); + await stale(); + ({ snapshot, held } = await collectSnapshot()); + assert.deepEqual([snapshot.technitium ?? [], held.has(`technitium:${tId}`)], [[], true]); + await fresh(); + }); + + test("the Alerts page says where to look: DNS and zones under Services, blocking and block lists under Monitoring", async () => { + invalidateAlertsCache(); + const report = await getAlerts(true); + const find = (key: string) => report.alerts.find((x) => x.id.endsWith(key))!; + assert.deepEqual([find(`technitium-dns:${tId}`).category, find(`technitium-dns:${tId}`).source, find(`technitium-dns:${tId}`).link, find(`technitium-dns:${tId}`).target?.type], ["services", "Technitium DNS", "/technitium", "integration"]); + assert.equal(find(`technitium-zones:${tId}`).category, "services"); + assert.deepEqual([find(`technitium-blocking:${tId}`).category, find(`technitium-lists:${tId}`).category], ["monitoring", "monitoring"]); + }); + + test("the page: the DNS question, blocking, the statistics, the zones and what is wrong; an old reading says nothing is wrong", async () => { + const body = (await (await fetch(base)).json()) as { instances: { id: number; fresh: boolean; problems: unknown[]; state: { probe: { ok: boolean }; blockingEnabled: boolean; blockingOffSince: string | null; stats: { queries: number }; zones: { issues: unknown[] }; blockListsOverdueMs: number | null; settings: { blockLists: { count: number } } } }[] }; + const t = body.instances.find((x) => x.id === tId)!; + assert.deepEqual([t.fresh, t.problems.length, t.state.probe.ok, t.state.blockingEnabled, t.state.blockingOffSince !== null, t.state.stats.queries, t.state.zones.issues.length, t.state.settings.blockLists.count], [true, 4, false, false, true, 1000, 1, 2]); + assert.ok((t.state.blockListsOverdueMs ?? 0) >= 9 * HOUR); + await stale(); + const old = (await (await fetch(base)).json()) as typeof body; + assert.deepEqual(old.instances.find((x) => x.id === tId)!.problems, []); + await fresh(); + }); + + test("/metrics has DNS up, blocking, how long it has run, the queries, the zones with a problem — only while the reading is recent", async () => { + let text = await buildMetrics(new Date()); + assert.match(text, /homelab_technitium_dns_up\{name="Home DNS 2"\} 0/); + assert.doesNotMatch(text, /homelab_technitium_dns_probe_seconds/, "no answer, no time"); + assert.match(text, /homelab_technitium_blocking_enabled\{name="Home DNS 2"\} 0/); + assert.match(text, /homelab_technitium_block_lists_overdue\{name="Home DNS 2"\} 1/); + assert.match(text, /homelab_technitium_queries\{name="Home DNS 2"\} 1000/); + assert.match(text, /homelab_technitium_blocked\{name="Home DNS 2"\} 100/); + assert.match(text, /homelab_technitium_cache_entries\{name="Home DNS 2"\} 4000/); + assert.match(text, /homelab_technitium_zone_problems\{name="Home DNS 2"\} 1/); + assert.match(text, /homelab_technitium_dhcp_leases\{name="Home DNS 2"\} 12/); + assert.match(text, /homelab_technitium_uptime_seconds\{name="Home DNS 2"\} 4\d{5}/); + await stale(); + text = await buildMetrics(new Date()); + assert.doesNotMatch(text, /homelab_technitium_/); + await fresh(); + }); + + test("taking the integration away takes what was read with it", async () => { + await ts.forgetTechnitium(tId); + assert.equal((await ts.technitiumSyncStatuses())[tId], undefined); + await db.delete(integrations).where(eq(integrations.id, tId)); + assert.deepEqual(await db.select().from(technitiumState).where(eq(technitiumState.integrationId, tId)), []); + }); +}); diff --git a/web/src/App.tsx b/web/src/App.tsx index 7facffd..72d4f3c 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -23,6 +23,7 @@ import Hetzner from "./pages/Hetzner"; import GameServers from "./pages/GameServers"; import Media from "./pages/Media"; import AdguardHome from "./pages/AdguardHome"; +import TechnitiumDns from "./pages/TechnitiumDns"; import Grafana from "./pages/Grafana"; import Speedtest from "./pages/Speedtest"; import Costs from "./pages/Costs"; @@ -187,6 +188,7 @@ function Shelled({ user }: { user: CurrentUser }) { } /> } /> } /> + } /> } /> } /> } /> diff --git a/web/src/api/client.ts b/web/src/api/client.ts index f32f73f..71020d1 100644 --- a/web/src/api/client.ts +++ b/web/src/api/client.ts @@ -1519,6 +1519,61 @@ export interface AdguardInstance { problems: { key: string; message: string; severity: "warning" | "critical" }[]; } +/** One Technitium DNS Server (an integration of type technitium), as its page shows it. */ +export interface TechnitiumInstance { + id: number; + name: string; + enabled: boolean; + url: string; + status: { at: string; ok: boolean; error: string | null } | null; + fresh: boolean; + state: { + version: string | null; + /** When the DNS server last started. */ + startedAt: string | null; + dnsPort: number; + blockingEnabled: boolean; + blockingOffSince: string | null; + settings: { blockLists: { count: number; intervalHours: number | null; nextUpdate: string | null }; cacheMaximumEntries: number | null; recursion: string | null; dnssecValidation: boolean | null }; + /** The last day. */ + stats: { + period: string; + queries: number; + noError: number; + serverFailure: number; + nxDomain: number; + refused: number; + authoritative: number; + recursive: number; + cached: number; + blocked: number; + dropped: number; + clients: number; + zones: number | null; + cachedEntries: number | null; + allowedZones: number | null; + blockedZones: number | null; + allowListZones: number | null; + blockListZones: number | null; + blockedPercent: number | null; + cachedPercent: number | null; + failurePercent: number | null; + topClients: { name: string; count: number }[]; + topDomains: { name: string; count: number }[]; + topBlocked: { name: string; count: number }[]; + } | null; + zones: { total: number; disabled: number; issues: { name: string; problem: "expired" | "sync failed" }[] } | null; + dhcp: { scopes: number; enabledScopes: number; leases: number } | null; + /** The real DNS question put to it. */ + probe: { ok: boolean; ms: number | null; error: string | null; name: string; host: string } | null; + probeFailSince: string | null; + updatedAt: string; + /** How long ago the block lists were due for an update, when that is overdue; null otherwise. */ + blockListsOverdueMs: number | null; + } | null; + problems: { key: string; message: string; severity: "warning" | "critical" }[]; +} + /** One Grafana (an integration of type grafana), as its page shows it. */ export interface GrafanaInstance { id: number; @@ -2800,7 +2855,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" | "sonarr" | "radarr" | "prowlarr" | "adguard" | "grafana" | "lidarr" | "readarr"; +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" | "adguard" | "technitium" | "grafana" | "lidarr" | "readarr"; export interface IntegrationField { key: string; @@ -3407,6 +3462,9 @@ export const api = { save: (data: { enabled: boolean; alertAfterDays: number }) => request("/api/versions/settings", { method: "PUT", body: JSON.stringify(data) }), refresh: () => request("/api/versions/refresh", { method: "POST" }), }, + technitium: { + list: () => request<{ instances: TechnitiumInstance[] }>("/api/technitium"), + }, adguard: { list: () => request<{ instances: AdguardInstance[] }>("/api/adguard"), }, diff --git a/web/src/components/WallView.tsx b/web/src/components/WallView.tsx index b71bf7b..c249b96 100644 --- a/web/src/components/WallView.tsx +++ b/web/src/components/WallView.tsx @@ -35,6 +35,7 @@ const TYPE_LABELS: Record = { radarr: "Radarr", prowlarr: "Prowlarr", adguard: "AdGuard Home", + technitium: "Technitium DNS", grafana: "Grafana", lidarr: "Lidarr", readarr: "Readarr", diff --git a/web/src/layout/nav.tsx b/web/src/layout/nav.tsx index 0fea8ca..7a0b248 100644 --- a/web/src/layout/nav.tsx +++ b/web/src/layout/nav.tsx @@ -49,6 +49,7 @@ import { IconGitCommit, IconShieldCheck, IconShieldLock, + IconWorldWww, IconVersions, IconChartAreaLine, IconActivityHeartbeat, @@ -137,6 +138,7 @@ export const NAV: NavEntry[] = [ items: [ { to: "/dns", label: "DNS", icon: }, { to: "/adguard", label: "AdGuard Home", icon: }, + { to: "/technitium", label: "Technitium DNS", icon: }, { to: "/network/devices", label: "Network devices", icon: }, { to: "/proxy-hosts", label: "Proxy hosts", icon: }, { to: "/ipam", label: "IP Addresses", icon: }, diff --git a/web/src/pages/TechnitiumDns.tsx b/web/src/pages/TechnitiumDns.tsx new file mode 100644 index 0000000..c80316a --- /dev/null +++ b/web/src/pages/TechnitiumDns.tsx @@ -0,0 +1,261 @@ +import { useEffect, useState } from "react"; +import { Link } from "react-router-dom"; +import { api, type TechnitiumInstance } from "../api/client"; +import EmptyState from "../components/EmptyState"; +import TimeAgo from "../components/TimeAgo"; +import { BlockSkeleton } from "../components/Skeleton"; +import { ErrorNotice } from "../components/Notice"; +import { formatAgo } from "../utils/duration"; +import { readableError } from "../utils/errors"; + +function Badge({ a }: { a: TechnitiumInstance }) { + 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, tone }: { label: string; value: string; sub?: string | null; tone?: "bad" | "warn" }) { + return ( +
+
+
+
{label}
+
{value}
+ {sub &&
{sub}
} +
+
+
+ ); +} + +function Counted({ title, items, empty }: { title: string; items: { name: string; count: number }[]; empty: string }) { + const top = items[0]?.count ?? 0; + return ( +
+

{title}

+ {items.length === 0 &&
{empty}
} + {items.slice(0, 7).map((i) => ( +
+
+ {i.name} + {i.count.toLocaleString()} +
+
+
0 ? Math.max(2, (i.count / top) * 100) : 0}%` }} /> +
+
+ ))} +
+ ); +} + +/** "12 d 3 h", "5 h 20 min", "40 min": how long since a moment. */ +function upFor(startedAt: string, now: number = Date.now()): string { + const minutes = Math.max(0, Math.floor((now - Date.parse(startedAt)) / 60_000)); + if (minutes < 60) return `${minutes} min`; + const hours = Math.floor(minutes / 60); + if (hours < 24) return minutes % 60 ? `${hours} h ${minutes % 60} min` : `${hours} h`; + const days = Math.floor(hours / 24); + return hours % 24 ? `${days} d ${hours % 24} h` : `${days} d`; +} + +/** How the last day's queries were answered, as one bar: from the cache, resolved by the server, from its own zones, blocked, dropped. */ +const HOW: { key: "cached" | "recursive" | "authoritative" | "blocked" | "dropped"; label: string; className: string }[] = [ + { key: "cached", label: "from the cache", className: "bg-blue" }, + { key: "recursive", label: "resolved", className: "bg-azure" }, + { key: "authoritative", label: "from its own zones", className: "bg-green" }, + { key: "blocked", label: "blocked", className: "bg-orange" }, + { key: "dropped", label: "dropped", className: "bg-red" }, +]; + +function Card({ a }: { a: TechnitiumInstance }) { + const s = a.state; + const st = s?.stats ?? null; + const cacheMax = s?.settings.cacheMaximumEntries ?? null; + const cacheFill = st && st.cachedEntries !== null && cacheMax !== null && cacheMax > 0 ? Math.min(100, Math.round((st.cachedEntries / cacheMax) * 100)) : null; + return ( +
+
+

+ {a.name} {s?.version ? `v${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 && ( + <> +
+ + 0 ? "warn" : undefined} + /> + + + + = 200 && st.failurePercent >= 20 ? "warn" : undefined} + /> + + = 95 ? "warn" : undefined} + /> +
+ + {st && st.queries > 0 && ( +
+

How the queries were answered

+
+ {HOW.map((h) => ( +
+ ))} +
+
+ {HOW.map((h) => ( + +   + {h.label} {st[h.key].toLocaleString()} + + ))} +
+
+ )} + + {st && (st.topBlocked.length > 0 || st.topClients.length > 0 || st.topDomains.length > 0) && ( +
+ + + +
+ )} + +

Zones

+ {s.zones === null ? ( +
They could not be read.
+ ) : ( +
+
+ {s.zones.total} zone{s.zones.total === 1 ? "" : "s"} + {s.zones.disabled > 0 ? `, ${s.zones.disabled} switched off` : ""} + {s.zones.issues.length === 0 ? " — none with a problem." : "."} +
+ {s.zones.issues.length > 0 && ( +
    + {s.zones.issues.map((z) => ( +
  • + {z.name} — {z.problem === "expired" ? "expired: it no longer answers" : "cannot sync with its primary"} +
  • + ))} +
+ )} +
+ )} + +

Block lists and the rest

+
    +
  • + {s.settings.blockLists.count === 0 ? ( + "No block lists are set up." + ) : ( + <> + {s.settings.blockLists.count} block list{s.settings.blockLists.count === 1 ? "" : "s"} + {st && st.blockListZones !== null ? `, ${st.blockListZones.toLocaleString()} names on them` : ""} + {s.settings.blockLists.nextUpdate ? ( + s.blockListsOverdueMs !== null ? ( + + {" "} + — update was due + + ) : ( + — next update {new Date(s.settings.blockLists.nextUpdate).toLocaleString()} + ) + ) : ( + "" + )} + + )} +
  • + {st && (st.allowedZones !== null || st.blockedZones !== null) && ( +
  • + Allowed by hand: {(st.allowedZones ?? 0).toLocaleString()} · blocked by hand: {(st.blockedZones ?? 0).toLocaleString()} +
  • + )} +
  • + Recursion: {s.settings.recursion ?? "—"} · DNSSEC validation: {s.settings.dnssecValidation === null ? "—" : s.settings.dnssecValidation ? "on" : "off"} +
  • + {s.dhcp && ( +
  • + DHCP: {s.dhcp.scopes} scope{s.dhcp.scopes === 1 ? "" : "s"} ({s.dhcp.enabledScopes} on), {s.dhcp.leases.toLocaleString()} lease{s.dhcp.leases === 1 ? "" : "s"} +
  • + )} +
+ + )} +
+
+ ); +} + +/** Technitium DNS Server: whether DNS really answers, whether it blocks, what it has done in the last day, how its zones and block lists are, and how it is doing. */ +export default function TechnitiumDns() { + const [data, setData] = useState(null); + const [error, setError] = useState(null); + useEffect(() => { + const load = () => + api.technitium + .list() + .then((r) => { + setData(r.instances); + setError(null); + }) + .catch((err) => setError(readableError(err))); + void load(); + const t = setInterval(load, 60_000); + return () => clearInterval(t); + }, []); + return ( + <> +

Technitium DNS

+

+ Read every two minutes (see Integrations), with a real DNS question put to it each time — its web console can be up while DNS is not. Nothing is changed. DNS that stops answering, blocking left off for an hour,{" "} + block lists that stopped updating and an expired or unsynced zone are alerts — see Alerts. Technitium does not report the CPU, memory or disk of the machine it runs on: put a server agent there for that. +

+ + {!data && !error && } + {data && data.length === 0 && ( +
+
+ +
+
+ )} + {data?.map((a) => )} + + ); +} diff --git a/web/src/utils/integrationTypes.ts b/web/src/utils/integrationTypes.ts index fb79a09..5cb07a5 100644 --- a/web/src/utils/integrationTypes.ts +++ b/web/src/utils/integrationTypes.ts @@ -31,6 +31,7 @@ export const TYPE_LABELS: Record = { radarr: "Radarr", prowlarr: "Prowlarr", adguard: "AdGuard Home", + technitium: "Technitium DNS", grafana: "Grafana", lidarr: "Lidarr", readarr: "Readarr", @@ -67,6 +68,7 @@ export const TYPE_PAGES: Record = { radarr: "/media", prowlarr: "/media", adguard: "/adguard", + technitium: "/technitium", grafana: "/grafana", lidarr: "/media", readarr: "/media", @@ -77,13 +79,13 @@ 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", "sonarr", "radarr", "lidarr", "readarr", "prowlarr", "immich", "paperless", "nextcloud", "authentik"] }, { id: "backups", label: "Backups", types: ["pbs"] }, - { id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard"] }, + { id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard", "technitium"] }, { id: "monitoring", label: "Monitoring", types: ["uptimekuma", "prometheus", "grafana", "ups", "speedtest"] }, { id: "automation", label: "Automation", types: ["semaphore", "gitea", "osticket", "n8n"] }, ]; /** The kinds whose reader can be inspected (Settings → Integrations → Check what can be read): the ones that read through the shared HTTP helper and have a reader to run. */ -export const INSPECTABLE: IntegrationType[] = ["authentik", "immich", "jellyfin", "netbox", "nextcloud", "paperless", "prometheus", "hetzner", "speedtest", "fragnet", "sonarr", "radarr", "prowlarr", "lidarr", "readarr", "adguard", "grafana"]; +export const INSPECTABLE: IntegrationType[] = ["authentik", "immich", "jellyfin", "netbox", "nextcloud", "paperless", "prometheus", "hetzner", "speedtest", "fragnet", "sonarr", "radarr", "prowlarr", "lidarr", "readarr", "adguard", "technitium", "grafana"]; /** The group a kind belongs to; a kind nobody has placed yet falls in "Other" rather than vanishing. */ export function groupOfType(type: IntegrationType): { id: string; label: string } {