mem_avail
This commit is contained in:
parent
d701098d84
commit
9645fb8dc2
@ -11,3 +11,11 @@ CREATE TABLE host_uptime (
|
|||||||
-- uptime in seconds
|
-- uptime in seconds
|
||||||
uptime INT NOT NULL
|
uptime INT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE host_mem (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
host_id INT NOT NULL REFERENCES host(id),
|
||||||
|
-- available memory in kB
|
||||||
|
mem_avail INT NOT NULL
|
||||||
|
);
|
12
status
12
status
@ -15,3 +15,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_mem (host_id, mem_avail)
|
||||||
|
SELECT id, '$(cat /proc/meminfo | grep 'MemAvailable' | awk '{print $2}')'
|
||||||
|
FROM host_upsert
|
||||||
|
RETURNING *;
|
||||||
|
EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user