Skip to content

Commit 269cdc0

Browse files
author
nikolay
committed
the very 1st script via menu
1 parent 987b08e commit 269cdc0

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

general/basic.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
select case when pg_is_in_recovery() then 'Replica' || ' (delay: '
2+
|| ((((case
3+
when pg_last_xlog_receive_location() = pg_last_xlog_replay_location() then 0
4+
else extract (epoch from now() - pg_last_xact_replay_timestamp())
5+
end)::int)::text || ' second')::interval)::text
6+
|| '; paused: ' || pg_is_xlog_replay_paused()::text || ')'
7+
else 'Master'
8+
end as "Node Information";

index.psql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
\echo Menu:
2-
\echo ' 1 – Database object sizes'
2+
\echo ' 1 – Master / replica info (with lag)'
33
\echo ' 2 – Bloat'
44
\echo ' 3 – pg_stat_statementis'
55
\echo ' q – Quit from this tool'
@@ -13,20 +13,21 @@ select
1313
:d_stp::text = '3' as d_step_is_3,
1414
:d_stp::text = 'q' as d_step_is_q \gset
1515
\if :d_step_is_1
16-
\echo ' 1 is chosen!'
16+
\i ./general/basic.sql
1717
\prompt 'Press any key…' d_dummy
18-
\i index.sql
18+
\i ./index.psql
1919
\elif :d_step_is_2
2020
\echo ' 2 is chosen!'
2121
\prompt 'Press any key…' d_dummy
22-
\i index.sql
22+
\i ./index.psql
2323
\elif :d_step_is_3
2424
\echo ' 3 is chosen!'
2525
\prompt 'Press any key…' d_dummy
26-
\i index.sql
26+
\i ./index.psql
2727
\elif :d_step_is_q
2828
\echo '...bye!'
2929
\else
3030
\echo 'ERROR: Unkown option!'
31-
\i index.sql
31+
\i ./index.psql
3232
\endif
33+

0 commit comments

Comments
 (0)