diff options
author | Facetoe <facetoe@facetoe.com.au> | 2017-08-09 21:49:09 +0800 |
---|---|---|
committer | Facetoe <facetoe@facetoe.com.au> | 2017-08-09 21:58:21 +0800 |
commit | 4262174fef8dca5206bf33e40400365db5c6eb5c (patch) | |
tree | 883f393395514e412a9dd5697bcce6325a97461a /python.d | |
parent | 2d6660fc9c80880f40804e0bc45520bd1d5507a3 (diff) |
Ensure configured user has the necessary permissions.
Diffstat (limited to 'python.d')
-rw-r--r-- | python.d/postgres.chart.py | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/python.d/postgres.chart.py b/python.d/postgres.chart.py index e9e0f841d6..b17565e9d3 100644 --- a/python.d/postgres.chart.py +++ b/python.d/postgres.chart.py @@ -118,30 +118,15 @@ GROUP BY datname, mode ORDER BY datname, mode; """, FIND_DATABASES=""" -SELECT datname FROM pg_stat_database WHERE NOT datname ~* '^template\d+' +SELECT datname +FROM pg_stat_database +WHERE has_database_privilege((SELECT current_user), datname, 'connect') +AND NOT datname ~* '^template\d+'; """, IF_SUPERUSER=""" SELECT current_setting('is_superuser') = 'on' AS is_superuser; """) -# REPLICATION = """ -# SELECT -# client_hostname, -# client_addr, -# state, -# sent_offset - ( -# replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ) AS byte_lag -# FROM ( -# SELECT -# client_addr, client_hostname, state, -# ('x' || lpad(split_part(sent_location::text, '/', 1), 8, '0'))::bit(32)::bigint AS sent_xlog, -# ('x' || lpad(split_part(replay_location::text, '/', 1), 8, '0'))::bit(32)::bigint AS replay_xlog, -# ('x' || lpad(split_part(sent_location::text, '/', 2), 8, '0'))::bit(32)::bigint AS sent_offset, -# ('x' || lpad(split_part(replay_location::text, '/', 2), 8, '0'))::bit(32)::bigint AS replay_offset -# FROM pg_stat_replication -# ) AS s; -# """ - QUERY_STATS = { QUERIES['DATABASE']: METRICS['DATABASE'], |