1PG_ACTIVITCYo(m1m)and line tool for PostgreSQL server activity monitorPiGn_gA.CTIVITY(1)
2
3
4

NAME

6       pg_activity - Realtime PostgreSQL database server monitoring tool
7

SYNOPSIS

9       pg_activity [option..] [connection string]
10

DESCRIPTION

12       Command line tool for PostgreSQL server activity monitoring.
13
14       pg_activity must run on the same server as the instance and as the user
15       running the instance (or root) to show CPU, MEM, READ or WRITE columns
16       and other system information.
17
18   THE HEADER
19       The first line of the header displays PostgreSQL's version, the host
20       name, the connection string and the refresh rate.
21
22       The rest of the header displays the following information:
23
24       - Size: size of the database you are connected to - Growth in B/s;
25       - Mem.: percentage of memory used - memory used / memory available;
26       - Swap: percentage of  swap used - swap used / swap available;
27       - Load: CPU load;
28       - TPS: transaction per second (sum of commit & rollback for all
29       databases / time elapsed since last snap);
30       - IO Max: the number of IO per second (aggregated data gathered with
31       the psutil library);
32       - Read: current Read throughput (aggregated data gathered with the
33       psutil library);
34       - Write: current Write throughput (aggregated data gathered with the
35       psutil library);
36       - Active connections: number of active connections;
37       - Duration mode: query, transaction or backend.
38
39   THE RUNNING QUERIES PANEL
40       The running queries panel shows all running queries, transactions or
41       backends (depending on the DURATION_MODE setting) which have lasted for
42       more than min duration seconds. It displays the following information:
43
44       - PID: process id of the backend which executes the query;
45       - DATABASE: database specified in the connection string;
46       - APP: application name specified in the connection string;
47       - USER: user name specified in the connection string;
48       - CLIENT: client address or "local" in case of linux socker connection;
49       - CPU%: percentage of CPU used by the backend as reported by the psutil
50       library;
51       - MEM%: percentage of memory used by the backend as reported by the
52       psutil library;
53       - READ/s:  read thruput as reported by the psutil library;
54       - WRITE/s: write thruput as reported by the psutil library;
55       - TIME: time since the beginning of the query / transaction / backend
56       start depending on the DURATION_MODE currently in use;
57       - Waiting: for PostgreSQL 9.6+: a specific wait event or nothing.
58       Otherwise, a boolean indicating if we are waiting for a Lock;
59       - IOW: boolean indicating that the process is waiting for IO as
60       reported by the psutil library;
61       - state: state of the backend;
62       - Query: the query.
63
64   THE WAITING QUERIES PANNEL
65       The waiting queries view displays queries that are wainting for a lock.
66       It shows the following information:
67
68       - PID: process id of the backend which executes the query;
69       - DATABASE: database specified in the connection string;
70       - APP: application name specified in the connection string;
71       - USER: user name specified in the connection string;
72       - CLIENT: client address or "local" in case of linux socker connection;
73       - RELATION: the name of the relation being locked if applicable;
74       - TYPE: the type of lock;
75       - MODE: the mode of the lock;
76       - TIME+: the duration of the query, transaction or session depending on
77       the DURATION_MODE setting;
78       - state: the state of the transaction;
79       - Query: the query.
80
81   THE BLOCKING QUERIES PANNEL
82       The blocking queries view displays the queries that lock an object
83       which is requiered by another session. It shows following information:
84
85       - PID: process id of the backend which executes the query;
86       - DATABASE: database specified in the connection string;
87       - APP: application name specified in the connection string;
88       - USER: user name specified in the connection string;
89       - CLIENT: client address or "local" in case of linux socker connection;
90       - RELATION: the name of the relation being locked if applicable;
91       - TYPE: the type of lock;
92       - MODE: the mode of the lock;
93       - TIME+: the duration of the query, transaction or session depending on
94       the DURATION_MODE setting;
95       - Waiting: for PostgreSQL 9.6+: a specific wait event or nothing.
96       Otherwise, a boolean indicating if we are waiting for a Lock;
97       - state: the state of the transaction;
98       - Query: the query.
99

COMMAND-LINE OPTIONS

101       -U USERNAME, --username=USERNAME
102                 Database user name.
103
104       -p PORT, --port=PORT
105                 Database server port.
106
107       -h HOSTNAME, --host=HOSTNAME
108                 Database server host or socket directory.
109
110       -d DBNAME, --dbname=DBNAME
111             Database name to connect to.
112
113       --blocksize=BLOCKSIZE
114                 Filesystem blocksize (default: 4096).
115
116       --rds
117                 Enable support for AWS RDS.
118
119       --output=FILEPATH
120                 Store running queries as CSV.
121
122       --no-db-size
123                 Skip total size of DB.
124
125       -w DISPLAY_MODE, --query-display-mode=DISPLAY_MODE
126                 Queries display mode. Values: 1-TRUNCATED, 2-FULL(default), 3-INDENTED
127
128       --duration-mode=DURATION_MODE
129                 Duration mode. Values: 1-QUERY(default), 2-TRANSACTION, 3-BACKEND
130
131       --min-duration=SECONDS
132                 Don't display queries with smaller than specified duration (in seconds).
133
134       --help
135                 Show this help message and exit.
136
137       --version
138                 Show program's version number and exit.
139

ENVIRONMENT VARIABLES

141         All the environnement variables supported by libpq (PostgreSQL's
142         query protocol) are supported by pg_activity.
143
144         See: https://www.postgresql.org/docs/current/libpq-envars.html
145

DISPLAY OPTIONS

147       --no-pid
148                 Disable PID.
149
150       --no-database
151                 Disable DATABASE.
152
153       --no-user
154                 Disable USER.
155
156       --no-client
157                 Disable CLIENT.
158
159       --no-cpu
160                 Disable CPU%.
161
162       --no-mem
163                 Disable MEM%.
164
165       --no-read
166                 Disable READ/s.
167
168       --no-write
169                 Disable WRITE/s.
170
171       --no-time
172                 Disable TIME+.
173
174       --no-wait
175                 Disable W.
176
177       --no-app-name
178                 Disable App.
179

INTERACTIVE COMMANDS

181       r     Sort by READ/s, descending.
182       w     Sort by WRITE/s, descending.
183       c     Sort by CPU%, descending.
184       m     Sort by MEM%, descending.
185       t     Sort by TIME+, descending.
186       T     Change duration mode: query, transaction, backend
187       Space Pause on/off.
188       v     Change queries display mode: full, truncated, indented
189       UP / DOWN Scroll process list.
190       k / j Scroll process list.
191       q     Quit
192       +     Increase refresh time. Maximum value: 3s
193       -     Decrease refresh time. Minimum Value: 1s
194       F1/1  Running queries monitoring.
195       F2/2  Waiting queries monitoring.
196       F3/3  Blocking queries monitoring.
197       h     Help page.
198       R     Refresh.
199       D     Refresh database size.
200
202       UP / k    Move up the cursor.
203       DOWN / j  Move down the cursor.
204       K     Terminate the current backend/tagged backends.
205       C     Cancel the current backend/tagged backends.
206       Space Tag or untag the process.
207       q     Quit.
208       Other Back to activity.
209

EXAMPLES

211       PGPASSWORD='mypassword' pg_activity -U pgadmin -h 127.0.0.1 --no-client
212
213       pg_activity -h /var/run/postgresql
214
215       pg_activity -h myserver -p 5433 -d nagios -U nagios
216
217
218
219pg_activity 2.2.1                 2021-08-05                    PG_ACTIVITY(1)
Impressum