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: README.md
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,17 @@
2
2
3
3
A collection of shell scripts for PostgreSQL database administrator (DBA). Tested on PostgreSQL 12-13 under CentOS 7.
4
4
5
-
-[scripts/pg_database_activity.sh](#pg_database_activity). PostgreSQL monitoring script, all information is displayed on one page. Displays PostgreSQL version and status (Master / Replica), hostname and IP address, CPU and Disks load. Shows the sizes of the main PostgreSQL directories, archived logs and free disk space, swap usage. It also displays memory consumption by PostgreSQL processes, statistics on databases, waits and locks, archive and replication statuses. When activities occur in PostgreSQL, the progress of operations is displayed: vacuum, vacuum full or cluster, index creation, analyze, pg_basebackup. At the end, the last entries of the PostgreSQL log file are displayed. For ease of perception, information is displayed in color.
6
-
-[scripts/pg_database_activity_refresh.sh](#pg_database_activity). Fast refresh of the **pg_database_activity.sh** script every 5 seconds.
5
+
[scripts/pg_database_activity.sh](#pg_database_activity). PostgreSQL monitoring script, all information is displayed on one page.
6
+
- Displays PostgreSQL version and status (Master / Replica), hostname and IP address, CPU and Disks load.
7
+
- Shows the sizes of the main PostgreSQL directories, archived logs and free disk space, swap usage.
8
+
- Displays memory consumption by PostgreSQL processes, statistics on databases, waits and locks, archive and replication statuses.
9
+
- When activities occur in PostgreSQL, the progress of operations is displayed: vacuum, vacuum full or cluster, index creation, analyze, pg_basebackup.
10
+
- At the end, the last entries of the PostgreSQL log file are displayed.
11
+
- For ease of perception, information is displayed in color.
12
+
13
+
[scripts/pg_database_activity_refresh.sh](#pg_database_activity). Fast refresh of the **pg_database_activity.sh** script every 5 seconds.
14
+
15
+
Small scripts to manage PostgreSQL:
7
16
-[scripts/pg_database_hugepages.sh](#pg_database_hugepages). Shows current usage of HugePages and recommended settings for PostgreSQL.
8
17
-[scripts/pg_database_start.sh](#pg_database_start). Start PostgreSQL, confirmation is required.
9
18
-[scripts/pg_database_stop.sh](#pg_database_stop). Stop PostgreSQL, confirmation is required.
Vacuum full command executing with Access Exclusive lock. Replication lag appeared (total_lag 3), archiving are not lagging behind (diff 1). The size of Archive logs increased to 609 MB. WalSender background process consumes 11.6% CPU, overall Disk load 14.76 %. The number of PostgreSQL log file entries has automatically decreased.
70
+
Vacuum full command executing with Access Exclusive lock. Replication lag appeared (total_lag 2721) on streaming and logical replication, archiving are not lagging behind (arc_diff 1). The size of Archive logs increased to 1.3 GB. WalSender background processes consumes 13.2% and 16.5% CPU, overall Disk load 9.73 %. The number of PostgreSQL log file entries has automatically decreased.
# pid_client_info=`$PG_BIN/psql -t -c "SELECT datname as database, usename as username, application_name, client_addr, backend_type, wait_event_type, wait_event FROM pg_stat_activity where pid=$pids;"`
#mem_cpu=`ps -q $pids -eo rss,pcpu | sed 1d | sed 's/ /|/'`
51
44
52
45
pid_client_info=`$PG_BIN/psql -t -c "SELECT datname as database, usename as username, application_name, client_addr, backend_type, wait_event_type, wait_event FROM pg_stat_activity where pid=$pids;"`
('x'||substring(last_archived_wal,17))::bit(32)::int as diff
152
+
('x'||substring(last_archived_wal,17))::bit(32)::int as arc_diff
173
153
--TO_CHAR(stats_reset, 'dd.mm.yyyy') as stats_reset
174
154
from pg_stat_archiver;"| grep -v row
175
155
else
@@ -185,11 +165,11 @@ fi
185
165
186
166
187
167
188
-
# Replication status
168
+
# Replication status (Master)
189
169
replication_status=`$PG_BIN/psql -t -c "select * from pg_stat_replication;"`
190
170
if [[ ${#replication_status}>0 ]];then
191
171
192
-
echo -e "${GREENLIGHT}Replication status:${NC}"
172
+
echo -e "${GREENLIGHT}Replication status (Master):${NC}"
193
173
$PG_BIN/psql -c "
194
174
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
175
(pg_wal_lsn_diff(pg_current_wal_lsn(), r.sent_lsn) / 1024)::int AS send_lag, -- sending_lag (network problems)
0 commit comments