File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 55__all__ += ['cfs' ]
66__all__ += ['archive_command' ]
77__all__ += ['relations_size' ]
8+ __all__ += ['prepared_transaction' ]
89
910from . import *
Original file line number Diff line number Diff line change @@ -82,11 +82,6 @@ def run(self, zbx):
8282
8383 zbx .send ('pgsql.relation.size[]' , zbx .json ({'data' : rels }))
8484
85-
86- def items (self , template ):
87-
88- return ''
89-
9085 def discovery_rules (self , template ):
9186 rule = {
9287 'name' : 'Relation size discovery' ,
Original file line number Diff line number Diff line change 117117RETURNS TABLE(SETTING TEXT) AS $$
118118select setting from pg_catalog.pg_settings where name = param
119119$$ LANGUAGE SQL SECURITY DEFINER;
120+
121+ CREATE OR REPLACE FUNCTION public.mamonsu_prepared_transaction()
122+ RETURNS TABLE(count_prepared BIGINT, oldest_prepared BIGINT) AS $$
123+ SELECT COUNT(*) AS count_prepared,
124+ coalesce (ROUND(MAX(EXTRACT (EPOCH FROM (now() - prepared)))),0)::bigint AS oldest_prepared
125+ FROM pg_catalog.pg_prepared_xacts$$ LANGUAGE SQL SECURITY DEFINER;
120126"""
121127
122128GrantsOnSchemaSQL = """
145151GRANT EXECUTE ON FUNCTION public.mamonsu_get_sys_param(param text) TO {1};
146152
147153GRANT EXECUTE ON FUNCTION public.mamonsu_get_connections_states() TO {1};
154+
155+ GRANT EXECUTE ON FUNCTION public.mamonsu_prepared_transaction() TO {1};
148156"""
Original file line number Diff line number Diff line change @@ -178,3 +178,11 @@ enabled = False
178178relations=pg_catalog.pg_class,pg_catalog.pg_user
179179interval = 500
180180
181+ # Get age in second and number of transactions that are currently prepared for two-phase commit.
182+ # https://www.postgresql.org/docs/current/sql-prepare-transaction.html
183+ # https://www.postgresql.org/docs/12/view-pg-prepared-xacts.html
184+ # max_prepared_transaction_time - age of prepared pransaction in second, after which the trigger run.
185+ # (возраст подготовленных транзакций, после которого срабатывает триггер.) ????
186+ [preparedtransaction]
187+ max_prepared_transaction_time = 60
188+ interval = 60
You can’t perform that action at this time.
0 commit comments