You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/pg_database_activity.sh
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -191,14 +191,16 @@ if [[ ${#replication_status} >0 ]]; then
191
191
192
192
echo -e "${GREENLIGHT}Replication status:${NC}"
193
193
$PG_BIN/psql -c "
194
-
SELECT client_addr AS client_addr, usename AS username, application_name AS app_name, pid, state, sync_state AS MODE,
195
-
(pg_wal_lsn_diff(pg_current_wal_lsn(), sent_lsn) / 1024)::int AS sending_lag, -- sending_lag (network problems)
196
-
(pg_wal_lsn_diff(sent_lsn, flush_lsn) / 1024)::int AS receiving_lag, -- receiving_lag
197
-
(pg_wal_lsn_diff(sent_lsn, write_lsn) / 1024)::int AS WRITE, -- disks problems
198
-
(pg_wal_lsn_diff(write_lsn, flush_lsn) / 1024)::int AS FLUSH, -- disks problems
199
-
(pg_wal_lsn_diff(flush_lsn, replay_lsn) / 1024)::int AS replaying_lag, -- replaying_lag (disks/CPU problems)
200
-
(pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn))::int / 1024 AS total_lag
201
-
FROM pg_stat_replication;"| grep -v row
194
+
SELECT r.client_addr AS client_addr, r.usename AS username, r.application_name AS app_name, r.pid, s.slot_name, s.slot_type, r.state, r.sync_state AS MODE,
195
+
(pg_wal_lsn_diff(pg_current_wal_lsn(), r.sent_lsn) / 1024)::int AS send_lag, -- sending_lag (network problems)
196
+
(pg_wal_lsn_diff(r.sent_lsn, r.flush_lsn) / 1024)::int AS receive_lag, -- receiving_lag
197
+
(pg_wal_lsn_diff(r.sent_lsn, r.write_lsn) / 1024)::int AS WRITE, -- disks problems
198
+
(pg_wal_lsn_diff(r.write_lsn, r.flush_lsn) / 1024)::int AS FLUSH, -- disks problems
199
+
(pg_wal_lsn_diff(r.flush_lsn, r.replay_lsn) / 1024)::int AS replay_lag, -- replaying_lag (disks/CPU problems)
200
+
(pg_wal_lsn_diff(pg_current_wal_lsn(), r.replay_lsn))::int / 1024 AS total_lag
201
+
FROM pg_stat_replication r, pg_replication_slots s
0 commit comments