]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/host_report.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 29 Oct 2024 09:53:28 +0000 (10:53 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 29 Oct 2024 09:53:28 +0000 (10:53 +0100)
lib/postgres/host_report.sql [new file with mode: 0644]

diff --git a/lib/postgres/host_report.sql b/lib/postgres/host_report.sql
new file mode 100644 (file)
index 0000000..c1dcd0a
--- /dev/null
@@ -0,0 +1,17 @@
+DROP VIEW IF EXISTS host_report;
+CREATE VIEW host_report AS
+       SELECT host
+               ,TO_CHAR(MAX(DISTINCT CASE WHEN key LIKE 'git.%' THEN updated ELSE null END),'YYYY-MM-DD HH:MI:SS') as git_updated
+               ,COUNT(DISTINCT CASE WHEN key LIKE 'git.%.path' THEN val ELSE null END) as git_path
+               ,MAX(DISTINCT CASE WHEN key LIKE 'git.%.exit_code' THEN val ELSE null END) as git_exit
+               ,array_to_string(array_agg(DISTINCT CASE WHEN key LIKE 'git.%.branch' THEN val ELSE null END),' ') as git_branch
+               ,TO_CHAR((SELECT MAX(hb.updated) FROM host_info hb WHERE hb.key LIKE CONCAT('backup_servers.',hi.host,'.%')),'YYYY-MM-DD HH:MI:SS') as backup_updated
+               ,(SELECT array_to_string(array_agg(DISTINCT hb.host),' ') FROM host_info hb WHERE hb.key LIKE CONCAT('backup_servers.',hi.host,'.time')) as backup_hosts
+               ,(SELECT MAX(hb.val) FROM host_info hb WHERE hb.key LIKE CONCAT('backup_servers.',hi.host,'.files_transfer')) as backup_files
+       FROM host_info hi
+       GROUP BY host
+       ORDER BY git_updated DESC,backup_updated DESC,host
+;
+GRANT ALL PRIVILEGES ON host_report TO nico;
+GRANT ALL PRIVILEGES ON host_report TO www;
+GRANT ALL PRIVILEGES ON host_report TO root;