]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/monitoring-ps.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / monitoring-ps.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>27.1. Standard Unix Tools</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="monitoring.html" title="Chapter 27. Monitoring Database Activity" /><link rel="next" href="monitoring-stats.html" title="27.2. The Cumulative Statistics System" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">27.1. Standard Unix Tools</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="monitoring.html" title="Chapter 27. Monitoring Database Activity">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="monitoring.html" title="Chapter 27. Monitoring Database Activity">Up</a></td><th width="60%" align="center">Chapter 27. Monitoring Database Activity</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="monitoring-stats.html" title="27.2. The Cumulative Statistics System">Next</a></td></tr></table><hr /></div><div class="sect1" id="MONITORING-PS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">27.1. Standard Unix Tools <a href="#MONITORING-PS" class="id_link">#</a></h2></div></div></div><a id="id-1.6.14.6.2" class="indexterm"></a><p>
3    On most Unix platforms, <span class="productname">PostgreSQL</span> modifies its
4    command title as reported by <code class="command">ps</code>, so that individual server
5    processes can readily be identified.  A sample display is
6
7 </p><pre class="screen">
8 $ ps auxww | grep ^postgres
9 postgres  15551  0.0  0.1  57536  7132 pts/0    S    18:02   0:00 postgres -i
10 postgres  15554  0.0  0.0  57536  1184 ?        Ss   18:02   0:00 postgres: background writer
11 postgres  15555  0.0  0.0  57536   916 ?        Ss   18:02   0:00 postgres: checkpointer
12 postgres  15556  0.0  0.0  57536   916 ?        Ss   18:02   0:00 postgres: walwriter
13 postgres  15557  0.0  0.0  58504  2244 ?        Ss   18:02   0:00 postgres: autovacuum launcher
14 postgres  15582  0.0  0.0  58772  3080 ?        Ss   18:04   0:00 postgres: joe runbug 127.0.0.1 idle
15 postgres  15606  0.0  0.0  58772  3052 ?        Ss   18:07   0:00 postgres: tgl regression [local] SELECT waiting
16 postgres  15610  0.0  0.0  58772  3056 ?        Ss   18:07   0:00 postgres: tgl regression [local] idle in transaction
17 </pre><p>
18
19    (The appropriate invocation of <code class="command">ps</code> varies across different
20    platforms, as do the details of what is shown.  This example is from a
21    recent Linux system.)  The first process listed here is the
22    primary server process.  The command arguments
23    shown for it are the same ones used when it was launched.  The next four
24    processes are background worker processes automatically launched by the
25    primary process.  (The <span class="quote">“<span class="quote">autovacuum launcher</span>”</span> process will not
26    be present if you have set the system not to run autovacuum.)
27    Each of the remaining
28    processes is a server process handling one client connection.  Each such
29    process sets its command line display in the form
30
31 </p><pre class="screen">
32 postgres: <em class="replaceable"><code>user</code></em> <em class="replaceable"><code>database</code></em> <em class="replaceable"><code>host</code></em> <em class="replaceable"><code>activity</code></em>
33 </pre><p>
34
35   The user, database, and (client) host items remain the same for
36   the life of the client connection, but the activity indicator changes.
37   The activity can be <code class="literal">idle</code> (i.e., waiting for a client command),
38   <code class="literal">idle in transaction</code> (waiting for client inside a <code class="command">BEGIN</code> block),
39   or a command type name such as <code class="literal">SELECT</code>.  Also,
40   <code class="literal">waiting</code> is appended if the server process is presently waiting
41   on a lock held by another session.  In the above example we can infer
42   that process 15606 is waiting for process 15610 to complete its transaction
43   and thereby release some lock.  (Process 15610 must be the blocker, because
44   there is no other active session.  In more complicated cases it would be
45   necessary to look into the
46   <a class="link" href="view-pg-locks.html" title="53.13. pg_locks"><code class="structname">pg_locks</code></a>
47   system view to determine who is blocking whom.)
48   </p><p>
49    If <a class="xref" href="runtime-config-logging.html#GUC-CLUSTER-NAME">cluster_name</a> has been configured the
50    cluster name will also be shown in <code class="command">ps</code> output:
51 </p><pre class="screen">
52 $ psql -c 'SHOW cluster_name'
53  cluster_name
54 --------------
55  server1
56 (1 row)
57
58 $ ps aux|grep server1
59 postgres   27093  0.0  0.0  30096  2752 ?        Ss   11:34   0:00 postgres: server1: background writer
60 ...
61 </pre><p>
62   </p><p>
63    If you have turned off <a class="xref" href="runtime-config-logging.html#GUC-UPDATE-PROCESS-TITLE">update_process_title</a> then the
64    activity indicator is not updated; the process title is set only once
65    when a new process is launched.  On some platforms this saves a measurable
66    amount of per-command overhead;  on others it's insignificant.
67   </p><div class="tip"><h3 class="title">Tip</h3><p>
68   <span class="productname">Solaris</span> requires special handling. You must
69   use <code class="command">/usr/ucb/ps</code>, rather than
70   <code class="command">/bin/ps</code>. You also must use two <code class="option">w</code>
71   flags, not just one. In addition, your original invocation of the
72   <code class="command">postgres</code> command must have a shorter
73   <code class="command">ps</code> status display than that provided by each
74   server process.  If you fail to do all three things, the <code class="command">ps</code>
75   output for each server process will be the original <code class="command">postgres</code>
76   command line.
77   </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="monitoring.html" title="Chapter 27. Monitoring Database Activity">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="monitoring.html" title="Chapter 27. Monitoring Database Activity">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="monitoring-stats.html" title="27.2. The Cumulative Statistics System">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 27. Monitoring Database Activity </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 27.2. The Cumulative Statistics System</td></tr></table></div></body></html>