Skip to content

Commit 3f3be95

Browse files
author
alexander popov
committed
fix pg_buffercache
1 parent a2acbf5 commit 3f3be95

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

mamonsu/plugins/pgsql/driver/pool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class Pool(object):
3232
'select public.mamonsu_count_autovacuum()'
3333
),
3434
'buffer_cache': (
35-
"select sum(1) * 8 * 1024 as size, "
36-
" sum(case when usagecount > 1 then 1 else 0 end) * 8 * 1024 as twice_used, "
37-
" sum(case isdirty when true then 1 else 0 end) * 8 * 1024 as dirty "
35+
"select sum(1) * (current_setting('block_size')::int8) as size, "
36+
" sum(case when usagecount > 1 then 1 else 0 end) * (current_setting('block_size')::int8) as twice_used, "
37+
" sum(case isdirty when true then 1 else 0 end) * (current_setting('block_size')::int8) as dirty "
3838
" from public.pg_buffercache",
3939
'select size, twice_used, dirty from public.mamonsu_buffer_cache()'
4040
),

mamonsu/plugins/pgsql/pg_buffercache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
class PgBufferCache(Plugin):
88
AgentPluginType = 'pg'
99
key = 'pgsql.buffers{0}'
10-
query_agent_size = "select sum(1) * 8 * 1024 as size from public.pg_buffercache;" # for zabbix
11-
query_agent_twice_used = "select sum(case when usagecount > 1 then 1 else 0 end) * 8 * 1024 as twice_used " \
10+
query_agent_size = "select sum(1) * (current_setting('block_size')::int8) as size from public.pg_buffercache;" # for zabbix
11+
query_agent_twice_used = "select sum(case when usagecount > 1 then 1 else 0 end) * (current_setting('block_size')::int8) as twice_used " \
1212
"from public.pg_buffercache;" # for zabbix
13-
query_agent_dirty = "select sum(case isdirty when true then 1 else 0 end) * 8 * 1024 as dirty " \
13+
query_agent_dirty = "select sum(case isdirty when true then 1 else 0 end) * (current_setting('block_size')::int8) as dirty " \
1414
"from public.pg_buffercache;" # for zabbix
1515
query = [query_agent_size, query_agent_twice_used, query_agent_dirty]
1616
Items = [

mamonsu/tools/bootstrap/sql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@
9595
CREATE OR REPLACE FUNCTION public.mamonsu_buffer_cache()
9696
RETURNS TABLE(SIZE BIGINT, TWICE_USED BIGINT, DIRTY BIGINT) AS $$
9797
SELECT
98-
SUM(1) * 8 * 1024,
99-
SUM(CASE WHEN usagecount > 1 THEN 1 ELSE 0 END) * 8 * 1024,
100-
SUM(CASE isdirty WHEN true THEN 1 ELSE 0 END) * 8 * 1024
98+
SUM(1) * (current_setting('block_size')::int8),
99+
SUM(CASE WHEN usagecount > 1 THEN 1 ELSE 0 END) * (current_setting('block_size')::int8),
100+
SUM(CASE isdirty WHEN true THEN 1 ELSE 0 END) * (current_setting('block_size')::int8)
101101
FROM public.pg_buffercache
102102
$$ LANGUAGE SQL SECURITY DEFINER;
103103

0 commit comments

Comments
 (0)