功能:完善云管助手与GPU故障恢复核对

This commit is contained in:
songyiming committed 2026-11-13 19:08:40 +08:00
1 parent b6026f9759
commit 9f7b01e4db
42 files changed
+3576 -120

No files matched your search

+26
View File
@@ -82,12 +82,27 @@ CREATE TABLE IF NOT EXISTS terminal_log_archives (
);
CREATE INDEX IF NOT EXISTS terminal_log_archives_terminal_time ON terminal_log_archives(terminal_id,captured_at DESC,id);
CREATE INDEX IF NOT EXISTS terminal_log_archives_time ON terminal_log_archives(captured_at DESC);
CREATE TABLE IF NOT EXISTS terminal_log_entries (
id text PRIMARY KEY, terminal_id text NOT NULL REFERENCES terminals(id) ON DELETE CASCADE,
captured_at timestamptz NOT NULL DEFAULT now(), boot_id text NOT NULL DEFAULT '', level text NOT NULL DEFAULT 'info',
message text NOT NULL, metadata jsonb NOT NULL DEFAULT '{}'::jsonb
);
CREATE INDEX IF NOT EXISTS terminal_log_entries_terminal_time ON terminal_log_entries(terminal_id,captured_at DESC,id);
CREATE INDEX IF NOT EXISTS terminal_log_entries_time ON terminal_log_entries(captured_at DESC);
CREATE TABLE IF NOT EXISTS assistant_runs (
id text PRIMARY KEY, actor text NOT NULL REFERENCES administrators(username), input_text text NOT NULL,
action text NOT NULL, status text NOT NULL CHECK(status IN ('planned','blocked','executed','expired','failed')),
plan jsonb NOT NULL, fingerprint text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(),
expires_at timestamptz NOT NULL, executed_at timestamptz, result jsonb NOT NULL DEFAULT '{}'::jsonb
);
CREATE INDEX IF NOT EXISTS assistant_runs_actor_time ON assistant_runs(actor,created_at DESC);
CREATE TABLE IF NOT EXISTS image_templates (
id text PRIMARY KEY, name text NOT NULL, version text NOT NULL, os text NOT NULL CHECK(os IN ('Windows','Ubuntu','麒麟')),
node text NOT NULL, vmid integer NOT NULL CHECK(vmid>=100), digest text NOT NULL,
enabled boolean NOT NULL DEFAULT true, validated_at timestamptz NOT NULL DEFAULT now(),
UNIQUE(node,vmid), UNIQUE(name,version)
);
ALTER TABLE image_templates ADD COLUMN IF NOT EXISTS hardware_encoding_verified boolean NOT NULL DEFAULT false;
CREATE TABLE IF NOT EXISTS desktop_pools (
id text PRIMARY KEY, name text NOT NULL UNIQUE, type text NOT NULL CHECK(type IN ('dedicated','shared')),
max_count integer NOT NULL CHECK(max_count BETWEEN 1 AND 10000),
@@ -124,6 +139,17 @@ CREATE TABLE IF NOT EXISTS resource_samples (
memory double precision, storage double precision, PRIMARY KEY(resource_id,sampled_at)
);
CREATE INDEX IF NOT EXISTS resource_samples_time ON resource_samples(sampled_at);
-- GPU health is reported by an explicitly configured node collector. PVE's
-- PCI inventory does not expose live temperature, utilization or VRAM usage.
CREATE TABLE IF NOT EXISTS gpu_health_samples (
node text NOT NULL, address text NOT NULL, observed_at timestamptz NOT NULL DEFAULT now(),
temperature_c double precision, utilization_percent double precision,
memory_used_bytes bigint, memory_total_bytes bigint,
driver text NOT NULL DEFAULT '', driver_binding text NOT NULL DEFAULT '', source text NOT NULL,
PRIMARY KEY(node,address,observed_at)
);
CREATE INDEX IF NOT EXISTS gpu_health_latest ON gpu_health_samples(node,address,observed_at DESC);
DELETE FROM gpu_health_samples WHERE observed_at < now() - interval '7 days';
CREATE TABLE IF NOT EXISTS alert_rules (
id text PRIMARY KEY, name text NOT NULL, metric text NOT NULL CHECK(metric IN ('node_cpu','node_memory','node_storage','node_unavailable','terminal_offline')),
threshold double precision NOT NULL, hold_seconds integer NOT NULL DEFAULT 0, enabled boolean NOT NULL DEFAULT true