Skip to content

Commit 858fbee

Browse files
committed
fix: change replication lag query for zabbix-agent
1 parent 0241146 commit 858fbee

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mamonsu/plugins/pgsql/xlog.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class Xlog(Plugin):
1111
"(pg_catalog.pg_current_wal_lsn(), '0/00000000');"
1212
query_xlog_lsn_diff = "select pg_catalog.pg_xlog_location_diff " \
1313
"(pg_catalog.pg_current_xlog_location(), '0/00000000');"
14+
query_agent_replication_lag = "SELECT CASE WHEN extract(epoch from now()-pg_last_xact_replay_timestamp()) " \
15+
"IS NULL THEN 0 ELSE extract(epoch from now()-pg_last_xact_replay_timestamp()) END"
1416
key_wall = 'pgsql.wal.write{0}'
1517
key_count_wall = "pgsql.wal.count{0}"
1618
key_replication = "pgsql.replication_lag{0}"
@@ -97,7 +99,6 @@ def keys_and_queries(self, template_zabbix):
9799
result.append(
98100
'{0},$2 $1 -c "{1}"'.format(self.key_count_wall.format('[*]'), Pooler.SQL['count_wal_files'][0]))
99101
result.append('{0},$2 $1 -c "{1}"'.format(self.key_wall.format('[*]'), self.query_wal_lsn_diff))
100-
# FIXME for lag
101102
result.append(
102-
'{0},$2 $1 -c "{1}"'.format("pgsql.replication_lag.sec[*]", Pooler.SQL['replication_lag_slave_query'][0]))
103+
'{0},$2 $1 -c "{1}"'.format("pgsql.replication_lag.sec[*]", self.query_agent_replication_lag))
103104
return template_zabbix.key_and_query(result)

0 commit comments

Comments
 (0)