cpu_load_1m
This commit is contained in:
parent
ff551e0f62
commit
6c8b9ace28
@ -27,3 +27,11 @@ CREATE TABLE host_disk (
|
|||||||
-- free disk space in kB
|
-- free disk space in kB
|
||||||
disk_free INT NOT NULL
|
disk_free INT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE host_cpu (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
host_id INT NOT NULL REFERENCES host(id),
|
||||||
|
-- cpu load for last minute
|
||||||
|
cpu_load_1m FLOAT NOT NULL
|
||||||
|
);
|
||||||
|
12
status
12
status
@ -39,3 +39,15 @@ psql -w <<EOF
|
|||||||
FROM host_upsert
|
FROM host_upsert
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
EOF
|
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_cpu (host_id, cpu_load_1m)
|
||||||
|
SELECT id, '$(top -bn1 | head -1 | awk -F'load average: ' '{print $2}' | awk -F, '{print $1}')'
|
||||||
|
FROM host_upsert
|
||||||
|
RETURNING *;
|
||||||
|
EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user