2025-01-28 15:17:10 +01:00
|
|
|
CREATE TABLE host (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
name VARCHAR(255) NOT NULL UNIQUE
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE host_uptime (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2025-02-04 02:32:06 +01:00
|
|
|
host_id INT NOT NULL REFERENCES host(id) ON UPDATE CASCADE,
|
2025-01-28 15:17:10 +01:00
|
|
|
-- uptime in seconds
|
|
|
|
uptime INT NOT NULL
|
|
|
|
);
|
2025-01-29 12:43:27 +01:00
|
|
|
CREATE INDEX host_uptime_host_id_created_at_idx ON host_uptime(host_id, created_at);
|
2025-01-28 16:07:05 +01:00
|
|
|
|
|
|
|
CREATE TABLE host_mem (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2025-02-04 02:32:06 +01:00
|
|
|
host_id INT NOT NULL REFERENCES host(id) ON UPDATE CASCADE,
|
2025-01-28 16:07:05 +01:00
|
|
|
-- available memory in kB
|
|
|
|
mem_avail INT NOT NULL
|
2025-01-28 16:44:29 +01:00
|
|
|
);
|
2025-01-29 12:43:27 +01:00
|
|
|
CREATE INDEX host_mem_host_id_created_at_idx ON host_mem(host_id, created_at);
|
2025-01-28 16:44:29 +01:00
|
|
|
|
|
|
|
CREATE TABLE host_disk (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2025-02-04 02:32:06 +01:00
|
|
|
host_id INT NOT NULL REFERENCES host(id) ON UPDATE CASCADE,
|
2025-01-28 16:44:29 +01:00
|
|
|
-- free disk space in kB
|
|
|
|
disk_free INT NOT NULL
|
|
|
|
);
|
2025-01-29 12:43:27 +01:00
|
|
|
CREATE INDEX host_disk_host_id_created_at_idx ON host_disk(host_id, created_at);
|
2025-01-28 17:07:35 +01:00
|
|
|
|
|
|
|
CREATE TABLE host_cpu (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2025-02-04 02:32:06 +01:00
|
|
|
host_id INT NOT NULL REFERENCES host(id) ON UPDATE CASCADE,
|
2025-01-28 17:07:35 +01:00
|
|
|
-- cpu load for last minute
|
|
|
|
cpu_load_1m FLOAT NOT NULL
|
|
|
|
);
|
2025-01-29 12:43:27 +01:00
|
|
|
CREATE INDEX host_cpu_host_id_created_at_idx ON host_cpu(host_id, created_at);
|