Compare commits
5 Commits
6c8b9ace28
...
8568c6ea0d
Author | SHA1 | Date | |
---|---|---|---|
8568c6ea0d | |||
d2dbf7269b | |||
655039756b | |||
0b124687a7 | |||
7cb003defd |
@ -27,11 +27,3 @@ CREATE TABLE host_disk (
|
||||
-- free disk space in kB
|
||||
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,15 +39,3 @@ 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_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