Handle situations where directories don't exist
- The pgsql_tmp and archive_ready directories don't always exist. Since PG <=9.4 doesn't have the "missing_ok" parameter, we have to work around the missing directories explicitly.
This commit is contained in:
parent
174cac4ca6
commit
590425fae7
@ -120,13 +120,26 @@ metrics:
|
||||
type: row
|
||||
query:
|
||||
120000: >
|
||||
SELECT count(*) AS count, sum(size) AS size
|
||||
SELECT count(*) AS count, coalesce(sum(size), 0) AS size
|
||||
FROM pg_ls_tmpdir()
|
||||
WHERE name LIKE 'pgsql_tmp%'
|
||||
*: >
|
||||
SELECT count(*) AS count, sum(size) AS size
|
||||
FROM pg_ls_dir('base/pgsql_tmp/')
|
||||
WHERE name LIKE 'pgsql_tmp%'
|
||||
WHERE name LIKE 'pgsql_tmp%%'
|
||||
90500: >
|
||||
SELECT count(*) AS count, coalesce(sum((pg_stat_file(name)).size), 0) AS size
|
||||
FROM pg_ls_dir('base/pgsql_tmp/', true, false) AS name
|
||||
WHERE name LIKE 'pgsql_tmp%%'
|
||||
0: >
|
||||
SELECT
|
||||
CASE WHEN (
|
||||
SELECT count(*)
|
||||
FROM pg_ls_dir('base') AS
|
||||
base WHERE base = 'pgsql_tmp') = 0
|
||||
THEN 0
|
||||
ELSE (
|
||||
SELECT count(*)
|
||||
FROM pg_ls_dir('base/pgsql_tmp/') AS name
|
||||
WHERE name LIKE 'pgsql_tmp%%')
|
||||
END
|
||||
|
||||
|
||||
ready_archive_files:
|
||||
type: value
|
||||
@ -134,15 +147,27 @@ metrics:
|
||||
120000: >
|
||||
SELECT count(*) AS count
|
||||
FROM pg_ls_archive_statusdir()
|
||||
WHERE name LIKE '%.ready'
|
||||
WHERE name LIKE '%%.ready'
|
||||
100000: >
|
||||
SELECT count(*) AS count
|
||||
FROM pg_ls_dir('pg_wal/pgsql_tmp/')
|
||||
WHERE name LIKE '%.ready'
|
||||
*: >
|
||||
FROM pg_ls_dir('pg_wal/archive_status/', true, false) AS name
|
||||
WHERE name LIKE '%%.ready'
|
||||
90500: >
|
||||
SELECT count(*) AS count
|
||||
FROM pg_ls_dir('pg_xlog/pgsql_tmp/')
|
||||
WHERE name LIKE '%.ready'
|
||||
FROM pg_ls_dir('pg_xlog/archive_status/', true, false) AS name
|
||||
WHERE name LIKE '%%.ready'
|
||||
0: >
|
||||
SELECT
|
||||
CASE WHEN (
|
||||
SELECT count(*)
|
||||
FROM pg_ls_dir('pg_xlog/') AS f
|
||||
WHERE f = 'archive_status') = 0
|
||||
THEN 0
|
||||
ELSE (
|
||||
SELECT count(*) AS count
|
||||
FROM pg_ls_dir('pg_xlog/archive_status/') AS name
|
||||
WHERE name LIKE '%%.ready')
|
||||
END
|
||||
|
||||
|
||||
##
|
||||
|
||||
Loading…
Reference in New Issue
Block a user