@cryptotaxi247 / netdata-1 / commits / 4262174fe

Ensure configured user has the necessary permissions.

Facetoe committed Aug 9, 2017 at 21:49 UTC 4262174fef8dca5206bf33e40400365db5c6eb5c
1 file changed +4 -19
python.d/postgres.chart.py
+4 -19
@@ -118,30 +118,15 @@ GROUP BY datname, mode
118 ORDER BY datname, mode;
119 """,
120 FIND_DATABASES="""
121 -SELECT datname FROM pg_stat_database WHERE NOT datname ~* '^template\d+'
121 +SELECT datname
122 +FROM pg_stat_database
123 +WHERE has_database_privilege((SELECT current_user), datname, 'connect')
124 +AND NOT datname ~* '^template\d+';
125 """,
126 IF_SUPERUSER="""
127 SELECT current_setting('is_superuser') = 'on' AS is_superuser;
128 """)
129
127 -# REPLICATION = """
128 -# SELECT
129 -# client_hostname,
130 -# client_addr,
131 -# state,
132 -# sent_offset - (
133 -# replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ) AS byte_lag
134 -# FROM (
135 -# SELECT
136 -# client_addr, client_hostname, state,
137 -# ('x' || lpad(split_part(sent_location::text, '/', 1), 8, '0'))::bit(32)::bigint AS sent_xlog,
138 -# ('x' || lpad(split_part(replay_location::text, '/', 1), 8, '0'))::bit(32)::bigint AS replay_xlog,
139 -# ('x' || lpad(split_part(sent_location::text, '/', 2), 8, '0'))::bit(32)::bigint AS sent_offset,
140 -# ('x' || lpad(split_part(replay_location::text, '/', 2), 8, '0'))::bit(32)::bigint AS replay_offset
141 -# FROM pg_stat_replication
142 -# ) AS s;
143 -# """
144 -
130
131 QUERY_STATS = {
132 QUERIES['DATABASE']: METRICS['DATABASE'],