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 5
5
__all__ += ['cfs' ]
6
6
__all__ += ['archive_command' ]
7
7
__all__ += ['relations_size' ]
8
+ __all__ += ['prepared_transaction' ]
8
9
9
10
from . import *
Original file line number Diff line number Diff line change @@ -82,11 +82,6 @@ def run(self, zbx):
82
82
83
83
zbx .send ('pgsql.relation.size[]' , zbx .json ({'data' : rels }))
84
84
85
-
86
- def items (self , template ):
87
-
88
- return ''
89
-
90
85
def discovery_rules (self , template ):
91
86
rule = {
92
87
'name' : 'Relation size discovery' ,
Original file line number Diff line number Diff line change 117
117
RETURNS TABLE(SETTING TEXT) AS $$
118
118
select setting from pg_catalog.pg_settings where name = param
119
119
$$ 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;
120
126
"""
121
127
122
128
GrantsOnSchemaSQL = """
145
151
GRANT EXECUTE ON FUNCTION public.mamonsu_get_sys_param(param text) TO {1};
146
152
147
153
GRANT EXECUTE ON FUNCTION public.mamonsu_get_connections_states() TO {1};
154
+
155
+ GRANT EXECUTE ON FUNCTION public.mamonsu_prepared_transaction() TO {1};
148
156
"""
Original file line number Diff line number Diff line change @@ -178,3 +178,11 @@ enabled = False
178
178
relations=pg_catalog.pg_class,pg_catalog.pg_user
179
179
interval = 500
180
180
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