Python.d/postgres.chart.py PEP 8 code cleanup (#4298)
* python.d/postgres.chart.py PEP 8 cleanup Fixed formatting of container literals and some line lengths. * Clean up SQL code in python.d/postgres.chart.py * Really fix SQL code formatting. Patch courtesy of @anayrat.
Austin S. Hemmelgarn committed
Oct 11, 2018 at 09:05 UTC
f51f1f839e8eec96b580175d5a8d86ad63ee4a5c
1 file changed
+347
-204
python.d/postgres.chart.py
+347
-204
@@ -21,222 +21,310 @@ update_every = 1
21
priority = 60000
22
retries = 60
23
24
-METRICS = dict(
25
- DATABASE=['connections',
26
- 'xact_commit',
27
- 'xact_rollback',
28
- 'blks_read',
29
- 'blks_hit',
30
- 'tup_returned',
31
- 'tup_fetched',
32
- 'tup_inserted',
33
- 'tup_updated',
34
- 'tup_deleted',
35
- 'conflicts',
36
- 'temp_files',
37
- 'temp_bytes',
38
- 'size'],
39
- BACKENDS=['backends_active',
40
- 'backends_idle'],
41
- INDEX_STATS=['index_count',
42
- 'index_size'],
43
- TABLE_STATS=['table_size',
44
- 'table_count'],
45
- WAL=['written_wal',
46
- 'recycled_wal',
47
- 'total_wal'],
48
- WAL_WRITES=['wal_writes'],
49
- ARCHIVE=['ready_count',
50
- 'done_count',
51
- 'file_count'],
52
- BGWRITER=['checkpoint_scheduled',
53
- 'checkpoint_requested',
54
- 'buffers_checkpoint',
55
- 'buffers_clean',
56
- 'maxwritten_clean',
57
- 'buffers_backend',
58
- 'buffers_alloc',
59
- 'buffers_backend_fsync'],
60
- LOCKS=['ExclusiveLock',
61
- 'RowShareLock',
62
- 'SIReadLock',
63
- 'ShareUpdateExclusiveLock',
64
- 'AccessExclusiveLock',
65
- 'AccessShareLock',
66
- 'ShareRowExclusiveLock',
67
- 'ShareLock',
68
- 'RowExclusiveLock'],
69
- AUTOVACUUM=['analyze',
70
- 'vacuum_analyze',
71
- 'vacuum',
72
- 'vacuum_freeze',
73
- 'brin_summarize'],
74
- STANDBY_DELTA=['sent_delta',
75
- 'write_delta',
76
- 'flush_delta',
77
- 'replay_delta'
78
- ],
79
- REPSLOT_FILES=['replslot_wal_keep',
80
- 'replslot_files']
81
-
82
-)
83
-
84
-QUERIES = dict(
85
- WAL="""
24
+METRICS = {
25
+ 'DATABASE': [
26
+ 'connections',
27
+ 'xact_commit',
28
+ 'xact_rollback',
29
+ 'blks_read',
30
+ 'blks_hit',
31
+ 'tup_returned',
32
+ 'tup_fetched',
33
+ 'tup_inserted',
34
+ 'tup_updated',
35
+ 'tup_deleted',
36
+ 'conflicts',
37
+ 'temp_files',
38
+ 'temp_bytes',
39
+ 'size'
40
+ ],
41
+ 'BACKENDS': [
42
+ 'backends_active',
43
+ 'backends_idle'
44
+ ],
45
+ 'INDEX_STATS': [
46
+ 'index_count',
47
+ 'index_size'
48
+ ],
49
+ 'TABLE_STATS': [
50
+ 'table_size',
51
+ 'table_count'
52
+ ],
53
+ 'WAL': [
54
+ 'written_wal',
55
+ 'recycled_wal',
56
+ 'total_wal'
57
+ ],
58
+ 'WAL_WRITES': [
59
+ 'wal_writes'
60
+ ],
61
+ 'ARCHIVE': [
62
+ 'ready_count',
63
+ 'done_count',
64
+ 'file_count'
65
+ ],
66
+ 'BGWRITER': [
67
+ 'checkpoint_scheduled',
68
+ 'checkpoint_requested',
69
+ 'buffers_checkpoint',
70
+ 'buffers_clean',
71
+ 'maxwritten_clean',
72
+ 'buffers_backend',
73
+ 'buffers_alloc',
74
+ 'buffers_backend_fsync'
75
+ ],
76
+ 'LOCKS': [
77
+ 'ExclusiveLock',
78
+ 'RowShareLock',
79
+ 'SIReadLock',
80
+ 'ShareUpdateExclusiveLock',
81
+ 'AccessExclusiveLock',
82
+ 'AccessShareLock',
83
+ 'ShareRowExclusiveLock',
84
+ 'ShareLock',
85
+ 'RowExclusiveLock'
86
+ ],
87
+ 'AUTOVACUUM': [
88
+ 'analyze',
89
+ 'vacuum_analyze',
90
+ 'vacuum',
91
+ 'vacuum_freeze',
92
+ 'brin_summarize'
93
+ ],
94
+ 'STANDBY_DELTA': [
95
+ 'sent_delta',
96
+ 'write_delta',
97
+ 'flush_delta',
98
+ 'replay_delta'
99
+ ],
100
+ 'REPSLOT_FILES': [
101
+ 'replslot_wal_keep',
102
+ 'replslot_files'
103
+ ]
104
+}
105
+
106
+QUERIES = {
107
+ 'WAL': """
108
SELECT
87
- count(*) as total_wal,
88
- count(*) FILTER (WHERE type = 'recycled') AS recycled_wal,
89
- count(*) FILTER (WHERE type = 'written') AS written_wal
109
+ count(*) as total_wal,
110
+ count(*) FILTER (WHERE type = 'recycled') AS recycled_wal,
111
+ count(*) FILTER (WHERE type = 'written') AS written_wal
112
FROM
91
- (SELECT wal.name,
92
- pg_{0}file_name(CASE pg_is_in_recovery() WHEN true THEN NULL ELSE pg_current_{0}_{1}() END ),
93
- CASE WHEN wal.name > pg_{0}file_name(CASE pg_is_in_recovery() WHEN true THEN NULL ELSE pg_current_{0}_{1}() END ) THEN 'recycled'
94
- ELSE 'written'
95
- END AS type
96
- FROM pg_catalog.pg_ls_dir('pg_{0}') AS wal(name)
97
- WHERE name ~ '^[0-9A-F]{{24}}$'
98
- ORDER BY (pg_stat_file('pg_{0}/'||name)).modification, wal.name DESC) sub;
113
+ (SELECT
114
+ wal.name,
115
+ pg_{0}file_name(
116
+ CASE pg_is_in_recovery()
117
+ WHEN true THEN NULL
118
+ ELSE pg_current_{0}_{1}()
119
+ END ),
120
+ CASE
121
+ WHEN wal.name > pg_{0}file_name(
122
+ CASE pg_is_in_recovery()
123
+ WHEN true THEN NULL
124
+ ELSE pg_current_{0}_{1}()
125
+ END ) THEN 'recycled'
126
+ ELSE 'written'
127
+ END AS type
128
+ FROM pg_catalog.pg_ls_dir('pg_{0}') AS wal(name)
129
+ WHERE name ~ '^[0-9A-F]{{24}}$'
130
+ ORDER BY
131
+ (pg_stat_file('pg_{0}/'||name)).modification,
132
+ wal.name DESC) sub;
133
""",
100
- ARCHIVE="""
134
+ 'ARCHIVE': """
135
SELECT
136
CAST(COUNT(*) AS INT) AS file_count,
103
- CAST(COALESCE(SUM(CAST(archive_file ~ $r$\.ready$$r$ as INT)), 0) AS INT) AS ready_count,
104
- CAST(COALESCE(SUM(CAST(archive_file ~ $r$\.done$$r$ AS INT)), 0) AS INT) AS done_count
137
+ CAST(COALESCE(SUM(CAST(archive_file ~ $r$\.ready$$r$ as INT)),0) AS INT) AS ready_count,
138
+ CAST(COALESCE(SUM(CAST(archive_file ~ $r$\.done$$r$ AS INT)),0) AS INT) AS done_count
139
FROM
140
pg_catalog.pg_ls_dir('pg_{0}/archive_status') AS archive_files (archive_file);
141
""",
108
- BACKENDS="""
142
+ 'BACKENDS': """
143
SELECT
110
- count(*) - (SELECT count(*) FROM pg_stat_activity WHERE state = 'idle') AS backends_active,
111
- (SELECT count(*) FROM pg_stat_activity WHERE state = 'idle' ) AS backends_idle
112
-FROM pg_stat_activity;
144
+ count(*) - (SELECT count(*)
145
+ FROM pg_stat_activity
146
+ WHERE state = 'idle')
147
+ AS backends_active,
148
+ (SELECT count(*)
149
+ FROM pg_stat_activity
150
+ WHERE state = 'idle')
151
+ AS backends_idle
152
+FROM pg_stat_activity;
153
""",
114
- TABLE_STATS="""
154
+ 'TABLE_STATS': """
155
SELECT
116
- ((sum(relpages) * 8) * 1024) AS table_size,
117
- count(1) AS table_count
156
+ ((sum(relpages) * 8) * 1024) AS table_size,
157
+ count(1) AS table_count
158
FROM pg_class
159
WHERE relkind IN ('r', 't');
160
""",
121
- INDEX_STATS="""
161
+ 'INDEX_STATS': """
162
SELECT
123
- ((sum(relpages) * 8) * 1024) AS index_size,
124
- count(1) AS index_count
163
+ ((sum(relpages) * 8) * 1024) AS index_size,
164
+ count(1) AS index_count
165
FROM pg_class
126
-WHERE relkind = 'i';""",
127
- DATABASE="""
166
+WHERE relkind = 'i';
167
+""",
168
+ 'DATABASE': """
169
SELECT
129
- datname AS database_name,
130
- numbackends AS connections,
131
- xact_commit AS xact_commit,
132
- xact_rollback AS xact_rollback,
133
- blks_read AS blks_read,
134
- blks_hit AS blks_hit,
135
- tup_returned AS tup_returned,
136
- tup_fetched AS tup_fetched,
137
- tup_inserted AS tup_inserted,
138
- tup_updated AS tup_updated,
139
- tup_deleted AS tup_deleted,
140
- conflicts AS conflicts,
141
- pg_database_size(datname) AS size,
142
- temp_files AS temp_files,
143
- temp_bytes AS temp_bytes
170
+ datname AS database_name,
171
+ numbackends AS connections,
172
+ xact_commit AS xact_commit,
173
+ xact_rollback AS xact_rollback,
174
+ blks_read AS blks_read,
175
+ blks_hit AS blks_hit,
176
+ tup_returned AS tup_returned,
177
+ tup_fetched AS tup_fetched,
178
+ tup_inserted AS tup_inserted,
179
+ tup_updated AS tup_updated,
180
+ tup_deleted AS tup_deleted,
181
+ conflicts AS conflicts,
182
+ pg_database_size(datname) AS size,
183
+ temp_files AS temp_files,
184
+ temp_bytes AS temp_bytes
185
FROM pg_stat_database
145
-WHERE datname IN %(databases)s
146
-;
186
+WHERE datname IN %(databases)s ;
187
""",
148
- BGWRITER="""
188
+ 'BGWRITER': """
189
SELECT
150
- checkpoints_timed AS checkpoint_scheduled,
151
- checkpoints_req AS checkpoint_requested,
152
- buffers_checkpoint * current_setting('block_size')::numeric buffers_checkpoint,
153
- buffers_clean * current_setting('block_size')::numeric buffers_clean,
154
- maxwritten_clean,
155
- buffers_backend * current_setting('block_size')::numeric buffers_backend,
156
- buffers_alloc * current_setting('block_size')::numeric buffers_alloc,
157
- buffers_backend_fsync
190
+ checkpoints_timed AS checkpoint_scheduled,
191
+ checkpoints_req AS checkpoint_requested,
192
+ buffers_checkpoint * current_setting('block_size')::numeric buffers_checkpoint,
193
+ buffers_clean * current_setting('block_size')::numeric buffers_clean,
194
+ maxwritten_clean,
195
+ buffers_backend * current_setting('block_size')::numeric buffers_backend,
196
+ buffers_alloc * current_setting('block_size')::numeric buffers_alloc,
197
+ buffers_backend_fsync
198
FROM pg_stat_bgwriter;
199
""",
160
- LOCKS="""
200
+ 'LOCKS': """
201
SELECT
162
- pg_database.datname as database_name,
163
- mode,
164
- count(mode) AS locks_count
202
+ pg_database.datname as database_name,
203
+ mode,
204
+ count(mode) AS locks_count
205
FROM pg_locks
166
- INNER JOIN pg_database ON pg_database.oid = pg_locks.database
206
+INNER JOIN pg_database
207
+ ON pg_database.oid = pg_locks.database
208
GROUP BY datname, mode
209
ORDER BY datname, mode;
210
""",
170
- FIND_DATABASES="""
171
-SELECT datname
211
+ 'FIND_DATABASES': """
212
+SELECT
213
+ datname
214
FROM pg_stat_database
173
-WHERE has_database_privilege((SELECT current_user), datname, 'connect')
174
-AND NOT datname ~* '^template\d+';
215
+WHERE
216
+ has_database_privilege(
217
+ (SELECT current_user), datname, 'connect')
218
+ AND NOT datname ~* '^template\d ';
219
""",
176
- FIND_STANDBY="""
177
-SELECT application_name
220
+ 'FIND_STANDBY': """
221
+SELECT
222
+ application_name
223
FROM pg_stat_replication
224
WHERE application_name IS NOT NULL
225
GROUP BY application_name;
226
""",
182
- FIND_REPLICATION_SLOT="""
227
+ 'FIND_REPLICATION_SLOT': """
228
SELECT slot_name
229
FROM pg_replication_slots;
230
""",
186
- STANDBY_DELTA="""
187
-SELECT application_name,
188
- pg_{0}_{1}_diff(CASE pg_is_in_recovery() WHEN true THEN pg_last_{0}_receive_{1}() ELSE pg_current_{0}_{1}() END , sent_{1}) AS sent_delta,
189
- pg_{0}_{1}_diff(CASE pg_is_in_recovery() WHEN true THEN pg_last_{0}_receive_{1}() ELSE pg_current_{0}_{1}() END , write_{1}) AS write_delta,
190
- pg_{0}_{1}_diff(CASE pg_is_in_recovery() WHEN true THEN pg_last_{0}_receive_{1}() ELSE pg_current_{0}_{1}() END , flush_{1}) AS flush_delta,
191
- pg_{0}_{1}_diff(CASE pg_is_in_recovery() WHEN true THEN pg_last_{0}_receive_{1}() ELSE pg_current_{0}_{1}() END , replay_{1}) AS replay_delta
231
+ 'STANDBY_DELTA': """
232
+SELECT
233
+ application_name,
234
+ pg_{0}_{1}_diff(
235
+ CASE pg_is_in_recovery()
236
+ WHEN true THEN pg_last_{0}_receive_{1}()
237
+ ELSE pg_current_{0}_{1}()
238
+ END,
239
+ sent_{1}) AS sent_delta,
240
+ pg_{0}_{1}_diff(
241
+ CASE pg_is_in_recovery()
242
+ WHEN true THEN pg_last_{0}_receive_{1}()
243
+ ELSE pg_current_{0}_{1}()
244
+ END,
245
+ write_{1}) AS write_delta,
246
+ pg_{0}_{1}_diff(
247
+ CASE pg_is_in_recovery()
248
+ WHEN true THEN pg_last_{0}_receive_{1}()
249
+ ELSE pg_current_{0}_{1}()
250
+ END,
251
+ flush_{1}) AS flush_delta,
252
+ pg_{0}_{1}_diff(
253
+ CASE pg_is_in_recovery()
254
+ WHEN true THEN pg_last_{0}_receive_{1}()
255
+ ELSE pg_current_{0}_{1}()
256
+ END,
257
+ replay_{1}) AS replay_delta
258
FROM pg_stat_replication
259
WHERE application_name IS NOT NULL;
260
""",
195
- REPSLOT_FILES="""
261
+ 'REPSLOT_FILES': """
262
WITH wal_size AS (
197
- SELECT current_setting('wal_block_size')::INT * setting::INT AS val
198
- FROM pg_settings
199
- WHERE name = 'wal_segment_size'
200
-)
201
-SELECT slot_name, slot_type, replslot_wal_keep, count(slot_file) AS replslot_files
202
-FROM (
203
- SELECT slot.slot_name, CASE WHEN slot_file <> 'state' THEN 1 END AS slot_file , slot_type,
204
- COALESCE (floor((pg_wal_lsn_diff (pg_current_wal_lsn (),
205
- slot.restart_lsn) - (pg_walfile_name_offset (restart_lsn)).file_offset) / (s.val)),
206
- 0) AS replslot_wal_keep
207
- FROM pg_replication_slots slot
208
- LEFT JOIN (
209
- SELECT slot2.slot_name,
210
- pg_ls_dir('pg_replslot/' || slot2.slot_name) AS slot_file
211
- FROM pg_replication_slots slot2
212
- ) files (slot_name, slot_file)
213
- ON slot.slot_name = files.slot_name
214
- CROSS JOIN wal_size s) AS d
215
-GROUP BY slot_name, slot_type, replslot_wal_keep;
263
+ SELECT
264
+ current_setting('wal_block_size')::INT * setting::INT AS val
265
+ FROM pg_settings
266
+ WHERE name = 'wal_segment_size'
267
+ )
268
+SELECT
269
+ slot_name,
270
+ slot_type,
271
+ replslot_wal_keep,
272
+ count(slot_file) AS replslot_files
273
+FROM
274
+ (SELECT
275
+ slot.slot_name,
276
+ CASE
277
+ WHEN slot_file <> 'state' THEN 1
278
+ END AS slot_file ,
279
+ slot_type,
280
+ COALESCE (
281
+ floor(
282
+ (pg_wal_lsn_diff(pg_current_wal_lsn (),slot.restart_lsn)
283
+ - (pg_walfile_name_offset (restart_lsn)).file_offset) / (s.val)
284
+ ),0) AS replslot_wal_keep
285
+ FROM pg_replication_slots slot
286
+ LEFT JOIN (
287
+ SELECT
288
+ slot2.slot_name,
289
+ pg_ls_dir('pg_replslot/' || slot2.slot_name) AS slot_file
290
+ FROM pg_replication_slots slot2
291
+ ) files (slot_name, slot_file)
292
+ ON slot.slot_name = files.slot_name
293
+ CROSS JOIN wal_size s
294
+ ) AS d
295
+GROUP BY
296
+ slot_name,
297
+ slot_type,
298
+ replslot_wal_keep;
299
""",
217
- IF_SUPERUSER="""
300
+ 'IF_SUPERUSER': """
301
SELECT current_setting('is_superuser') = 'on' AS is_superuser;
302
""",
220
- DETECT_SERVER_VERSION="""
303
+ 'DETECT_SERVER_VERSION': """
304
SHOW server_version_num;
305
""",
223
- AUTOVACUUM="""
306
+ 'AUTOVACUUM': """
307
SELECT
225
- count(*) FILTER (WHERE query LIKE 'autovacuum: ANALYZE%%') AS analyze,
226
- count(*) FILTER (WHERE query LIKE 'autovacuum: VACUUM ANALYZE%%') AS vacuum_analyze,
227
- count(*) FILTER (WHERE query LIKE 'autovacuum: VACUUM%%'
228
- AND query NOT LIKE 'autovacuum: VACUUM ANALYZE%%'
229
- AND query NOT LIKE '%%to prevent wraparound%%') AS vacuum,
230
- count(*) FILTER (WHERE query LIKE '%%to prevent wraparound%%') AS vacuum_freeze,
231
- count(*) FILTER (WHERE query LIKE 'autovacuum: BRIN summarize%%') AS brin_summarize
308
+ count(*) FILTER (WHERE query LIKE 'autovacuum: ANALYZE%%') AS analyze,
309
+ count(*) FILTER (WHERE query LIKE 'autovacuum: VACUUM ANALYZE%%') AS vacuum_analyze,
310
+ count(*) FILTER (WHERE query LIKE 'autovacuum: VACUUM%%'
311
+ AND query NOT LIKE 'autovacuum: VACUUM ANALYZE%%'
312
+ AND query NOT LIKE '%%to prevent wraparound%%') AS vacuum,
313
+ count(*) FILTER (WHERE query LIKE '%%to prevent wraparound%%') AS vacuum_freeze,
314
+ count(*) FILTER (WHERE query LIKE 'autovacuum: BRIN summarize%%') AS brin_summarize
315
FROM pg_stat_activity
316
WHERE query NOT LIKE '%%pg_stat_activity%%';
317
""",
235
- DIFF_LSN="""
236
-SELECT pg_{0}_{1}_diff(CASE pg_is_in_recovery() WHEN true THEN pg_last_{0}_receive_{1}() ELSE pg_current_{0}_{1}() END, '0/0') as wal_writes ;
318
+ 'DIFF_LSN': """
319
+SELECT
320
+ pg_{0}_{1}_diff(
321
+ CASE pg_is_in_recovery()
322
+ WHEN true THEN pg_last_{0}_receive_{1}()
323
+ ELSE pg_current_{0}_{1}()
324
+ END,
325
+ '0/0') as wal_writes ;
326
"""
238
-
239
-)
327
+}
328
329
330
QUERY_STATS = {
@@ -245,11 +333,34 @@ QUERY_STATS = {
333
QUERIES['LOCKS']: METRICS['LOCKS']
334
}
335
248
-ORDER = ['db_stat_temp_files', 'db_stat_temp_bytes', 'db_stat_blks', 'db_stat_tuple_returned', 'db_stat_tuple_write',
249
- 'db_stat_transactions', 'db_stat_connections', 'database_size', 'backend_process', 'index_count', 'index_size',
250
- 'table_count', 'table_size', 'wal', 'wal_writes', 'archive_wal', 'checkpointer', 'stat_bgwriter_alloc', 'stat_bgwriter_checkpoint',
251
- 'stat_bgwriter_backend', 'stat_bgwriter_backend_fsync', 'stat_bgwriter_bgwriter', 'stat_bgwriter_maxwritten',
252
- 'replication_slot', 'standby_delta', 'autovacuum']
336
+ORDER = [
337
+ 'db_stat_temp_files',
338
+ 'db_stat_temp_bytes',
339
+ 'db_stat_blks',
340
+ 'db_stat_tuple_returned',
341
+ 'db_stat_tuple_write',
342
+ 'db_stat_transactions',
343
+ 'db_stat_connections',
344
+ 'database_size',
345
+ 'backend_process',
346
+ 'index_count',
347
+ 'index_size',
348
+ 'table_count',
349
+ 'table_size',
350
+ 'wal',
351
+ 'wal_writes',
352
+ 'archive_wal',
353
+ 'checkpointer',
354
+ 'stat_bgwriter_alloc',
355
+ 'stat_bgwriter_checkpoint',
356
+ 'stat_bgwriter_backend',
357
+ 'stat_bgwriter_backend_fsync',
358
+ 'stat_bgwriter_bgwriter',
359
+ 'stat_bgwriter_maxwritten',
360
+ 'replication_slot',
361
+ 'standby_delta',
362
+ 'autovacuum'
363
+]
364
365
CHARTS = {
366
'db_stat_transactions': {
@@ -258,26 +369,30 @@ CHARTS = {
369
'lines': [
370
['xact_commit', 'committed', 'incremental'],
371
['xact_rollback', 'rolled back', 'incremental']
261
- ]},
372
+ ]
373
+ },
374
'db_stat_connections': {
375
'options': [None, 'Current connections to db', 'count', 'db statistics', 'postgres.db_stat_connections',
376
'line'],
377
'lines': [
378
['connections', 'connections', 'absolute']
267
- ]},
379
+ ]
380
+ },
381
'db_stat_blks': {
382
'options': [None, 'Disk blocks reads from db', 'reads/s', 'db statistics', 'postgres.db_stat_blks', 'line'],
383
'lines': [
384
['blks_read', 'disk', 'incremental'],
385
['blks_hit', 'cache', 'incremental']
273
- ]},
386
+ ]
387
+ },
388
'db_stat_tuple_returned': {
389
'options': [None, 'Tuples returned from db', 'tuples/s', 'db statistics', 'postgres.db_stat_tuple_returned',
390
'line'],
391
'lines': [
392
['tup_returned', 'sequential', 'incremental'],
393
['tup_fetched', 'bitmap', 'incremental']
280
- ]},
394
+ ]
395
+ },
396
'db_stat_tuple_write': {
397
'options': [None, 'Tuples written to db', 'writes/s', 'db statistics', 'postgres.db_stat_tuple_write', 'line'],
398
'lines': [
@@ -285,103 +400,128 @@ CHARTS = {
400
['tup_updated', 'updated', 'incremental'],
401
['tup_deleted', 'deleted', 'incremental'],
402
['conflicts', 'conflicts', 'incremental']
288
- ]},
403
+ ]
404
+ },
405
'db_stat_temp_bytes': {
290
- 'options': [None, 'Temp files written to disk', 'KB/s', 'db statistics', 'postgres.db_stat_temp_bytes', 'line'],
406
+ 'options': [None, 'Temp files written to disk', 'KB/s', 'db statistics', 'postgres.db_stat_temp_bytes',
407
+ 'line'],
408
'lines': [
409
['temp_bytes', 'size', 'incremental', 1, 1024]
293
- ]},
410
+ ]
411
+ },
412
'db_stat_temp_files': {
295
- 'options': [None, 'Temp files written to disk', 'files', 'db statistics', 'postgres.db_stat_temp_files', 'line'],
413
+ 'options': [None, 'Temp files written to disk', 'files', 'db statistics', 'postgres.db_stat_temp_files',
414
+ 'line'],
415
'lines': [
416
['temp_files', 'files', 'incremental']
298
- ]},
417
+ ]
418
+ },
419
'database_size': {
420
'options': [None, 'Database size', 'MB', 'database size', 'postgres.db_size', 'stacked'],
421
'lines': [
302
- ]},
422
+ ]
423
+ },
424
'backend_process': {
425
'options': [None, 'Current Backend Processes', 'processes', 'backend processes', 'postgres.backend_process',
426
'line'],
427
'lines': [
428
['backends_active', 'active', 'absolute'],
429
['backends_idle', 'idle', 'absolute']
309
- ]},
430
+ ]
431
+ },
432
'index_count': {
433
'options': [None, 'Total indexes', 'index', 'indexes', 'postgres.index_count', 'line'],
434
'lines': [
435
['index_count', 'total', 'absolute']
314
- ]},
436
+ ]
437
+ },
438
'index_size': {
439
'options': [None, 'Indexes size', 'MB', 'indexes', 'postgres.index_size', 'line'],
440
'lines': [
441
['index_size', 'size', 'absolute', 1, 1024 * 1024]
319
- ]},
442
+ ]
443
+ },
444
'table_count': {
445
'options': [None, 'Total Tables', 'tables', 'tables', 'postgres.table_count', 'line'],
446
'lines': [
447
['table_count', 'total', 'absolute']
324
- ]},
448
+ ]
449
+ },
450
'table_size': {
451
'options': [None, 'Tables size', 'MB', 'tables', 'postgres.table_size', 'line'],
452
'lines': [
453
['table_size', 'size', 'absolute', 1, 1024 * 1024]
329
- ]},
454
+ ]
455
+ },
456
'wal': {
457
'options': [None, 'Write-Ahead Logs', 'files', 'wal', 'postgres.wal', 'line'],
458
'lines': [
459
['written_wal', 'written', 'absolute'],
460
['recycled_wal', 'recycled', 'absolute'],
461
['total_wal', 'total', 'absolute']
336
- ]},
462
+ ]
463
+ },
464
'wal_writes': {
465
'options': [None, 'Write-Ahead Logs', 'kilobytes/s', 'wal_writes', 'postgres.wal_writes', 'line'],
466
'lines': [
467
['wal_writes', 'writes', 'incremental', 1, 1024]
341
- ]},
468
+ ]
469
+ },
470
'archive_wal': {
471
'options': [None, 'Archive Write-Ahead Logs', 'files/s', 'archive wal', 'postgres.archive_wal', 'line'],
472
'lines': [
473
['file_count', 'total', 'incremental'],
474
['ready_count', 'ready', 'incremental'],
475
['done_count', 'done', 'incremental']
348
- ]},
476
+ ]
477
+ },
478
'checkpointer': {
479
'options': [None, 'Checkpoints', 'writes', 'checkpointer', 'postgres.checkpointer', 'line'],
480
'lines': [
481
['checkpoint_scheduled', 'scheduled', 'incremental'],
482
['checkpoint_requested', 'requested', 'incremental']
354
- ]},
483
+ ]
484
+ },
485
'stat_bgwriter_alloc': {
486
'options': [None, 'Buffers allocated', 'kilobytes/s', 'bgwriter', 'postgres.stat_bgwriter_alloc', 'line'],
487
'lines': [
488
['buffers_alloc', 'alloc', 'incremental', 1, 1024]
359
- ]},
489
+ ]
490
+ },
491
'stat_bgwriter_checkpoint': {
361
- 'options': [None, 'Buffers written during checkpoints', 'kilobytes/s', 'bgwriter', 'postgres.stat_bgwriter_checkpoint', 'line'],
492
+ 'options': [None, 'Buffers written during checkpoints', 'kilobytes/s', 'bgwriter',
493
+ 'postgres.stat_bgwriter_checkpoint', 'line'],
494
'lines': [
495
['buffers_checkpoint', 'checkpoint', 'incremental', 1, 1024]
364
- ]},
496
+ ]
497
+ },
498
'stat_bgwriter_backend': {
366
- 'options': [None, 'Buffers written directly by a backend', 'kilobytes/s', 'bgwriter', 'postgres.stat_bgwriter_backend', 'line'],
499
+ 'options': [None, 'Buffers written directly by a backend', 'kilobytes/s', 'bgwriter',
500
+ 'postgres.stat_bgwriter_backend', 'line'],
501
'lines': [
502
['buffers_backend', 'backend', 'incremental', 1, 1024]
369
- ]},
503
+ ]
504
+ },
505
'stat_bgwriter_backend_fsync': {
506
'options': [None, 'Fsync by backend', 'times', 'bgwriter', 'postgres.stat_bgwriter_backend_fsync', 'line'],
507
'lines': [
508
['buffers_backend_fsync', 'backend fsync', 'incremental']
374
- ]},
509
+ ]
510
+ },
511
'stat_bgwriter_bgwriter': {
376
- 'options': [None, 'Buffers written by the background writer', 'kilobytes/s', 'bgwriter', 'postgres.bgwriter_bgwriter', 'line'],
512
+ 'options': [None, 'Buffers written by the background writer', 'kilobytes/s', 'bgwriter',
513
+ 'postgres.bgwriter_bgwriter', 'line'],
514
'lines': [
515
['buffers_clean', 'clean', 'incremental', 1, 1024]
379
- ]},
516
+ ]
517
+ },
518
'stat_bgwriter_maxwritten': {
381
- 'options': [None, 'Too many buffers written', 'times', 'bgwriter', 'postgres.stat_bgwriter_maxwritten', 'line'],
519
+ 'options': [None, 'Too many buffers written', 'times', 'bgwriter', 'postgres.stat_bgwriter_maxwritten',
520
+ 'line'],
521
'lines': [
522
['maxwritten_clean', 'maxwritten', 'incremental']
384
- ]},
523
+ ]
524
+ },
525
'autovacuum': {
526
'options': [None, 'Autovacuum workers', 'workers', 'autovacuum', 'postgres.autovacuum', 'line'],
527
'lines': [
@@ -390,7 +530,8 @@ CHARTS = {
530
['vacuum_analyze', 'vacuum analyze', 'absolute'],
531
['vacuum_freeze', 'vacuum freeze', 'absolute'],
532
['brin_summarize', 'brin summarize', 'absolute']
393
- ]},
533
+ ]
534
+ },
535
'standby_delta': {
536
'options': [None, 'Standby delta', 'kilobytes', 'replication delta', 'postgres.standby_delta', 'line'],
537
'lines': [
@@ -398,13 +539,15 @@ CHARTS = {
539
['write_delta', 'write delta', 'absolute', 1, 1024],
540
['flush_delta', 'flush delta', 'absolute', 1, 1024],
541
['replay_delta', 'replay delta', 'absolute', 1, 1024]
401
- ]},
542
+ ]
543
+ },
544
'replication_slot': {
545
'options': [None, 'Replication slot files', 'files', 'replication slot', 'postgres.replication_slot', 'line'],
546
'lines': [
547
['replslot_wal_keep', 'wal keeped', 'absolute'],
548
['replslot_files', 'pg_replslot files', 'absolute']
407
- ]}
549
+ ]
550
+ }
551
}
552
553
@@ -464,7 +607,7 @@ class Service(SimpleService):
607
cursor.close()
608
609
if self.database_poll and isinstance(self.database_poll, str):
467
- self.databases = [dbase for dbase in self.databases if dbase in self.database_poll.split()]\
610
+ self.databases = [dbase for dbase in self.databases if dbase in self.database_poll.split()] \
611
or self.databases
612
613
self.locks_zeroed = populate_lock_types(self.databases)