disk_free
This commit is contained in:
parent
705afb2bbb
commit
ff551e0f62
10
schema.sql
10
schema.sql
@ -18,4 +18,12 @@ CREATE TABLE host_mem (
|
||||
host_id INT NOT NULL REFERENCES host(id),
|
||||
-- available memory in kB
|
||||
mem_avail INT NOT NULL
|
||||
);
|
||||
);
|
||||
|
||||
CREATE TABLE host_disk (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
host_id INT NOT NULL REFERENCES host(id),
|
||||
-- free disk space in kB
|
||||
disk_free INT NOT NULL
|
||||
);
|
||||
|
12
status
12
status
@ -27,3 +27,15 @@ psql -w <<EOF
|
||||
FROM host_upsert
|
||||
RETURNING *;
|
||||
EOF
|
||||
|
||||
psql -w <<EOF
|
||||
WITH host_upsert AS (
|
||||
INSERT INTO host (name) VALUES ('$(hostname)')
|
||||
ON CONFLICT (name) DO UPDATE SET name = EXCLUDED.name
|
||||
RETURNING id
|
||||
)
|
||||
INSERT INTO host_disk (host_id, disk_free)
|
||||
SELECT id, '$(df / | awk 'NR==2{print $4}')'
|
||||
FROM host_upsert
|
||||
RETURNING *;
|
||||
EOF
|
||||
|
Loading…
x
Reference in New Issue
Block a user