1PG_ACTIVITCYo(m1m)and line tool for PostgreSQL server activity monitorPiGn_gA.CTIVITY(1)
2
3
4
6 pg_activity - Realtime PostgreSQL database server monitoring tool
7
9 pg_activity [option..] [connection string]
10
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 required 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
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 --filter=FIELD:REGEX
135 Filter activities with a (case insensitive) regular expression applied on selected fields. Known fields are: dbname.
136
137 --help
138 Show this help message and exit.
139
140 --version
141 Show program's version number and exit.
142
144 All the environnement variables supported by libpq (PostgreSQL's
145 query protocol) are supported by pg_activity.
146
147 See: https://www.postgresql.org/docs/current/libpq-envars.html
148
150 --no-pid
151 Disable PID.
152
153 --no-database
154 Disable DATABASE.
155
156 --no-user
157 Disable USER.
158
159 --no-client
160 Disable CLIENT.
161
162 --no-cpu
163 Disable CPU%.
164
165 --no-mem
166 Disable MEM%.
167
168 --no-read
169 Disable READ/s.
170
171 --no-write
172 Disable WRITE/s.
173
174 --no-time
175 Disable TIME+.
176
177 --no-wait
178 Disable W.
179
180 --no-app-name
181 Disable App.
182
184 r Sort by READ/s, descending.
185 w Sort by WRITE/s, descending.
186 c Sort by CPU%, descending.
187 m Sort by MEM%, descending.
188 t Sort by TIME+, descending.
189 T Change duration mode: query, transaction, backend
190 Space Pause on/off.
191 v Change queries display mode: full, truncated, indented
192 UP / DOWN Scroll process list.
193 k / j Scroll process list.
194 q Quit
195 + Increase refresh time. Maximum value: 3s
196 - Decrease refresh time. Minimum Value: 1s
197 F1/1 Running queries monitoring.
198 F2/2 Waiting queries monitoring.
199 F3/3 Blocking queries monitoring.
200 h Help page.
201 R Refresh.
202 D Refresh database size.
203
205 UP / k Move up the cursor.
206 DOWN / j Move down the cursor.
207 K Terminate the current backend/tagged backends.
208 C Cancel the current backend/tagged backends.
209 Space Tag or untag the process.
210 q Quit.
211 Other Back to activity.
212
214 PGPASSWORD='mypassword' pg_activity -U pgadmin -h 127.0.0.1 --no-client
215
216 pg_activity -h /var/run/postgresql
217
218 pg_activity -h myserver -p 5433 -d nagios -U nagios
219
220
221
222pg_activity 2.2.1 2021-08-05 PG_ACTIVITY(1)