summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/monitoring-ps.html
blob: ea5c3ede44dd61e6a0fde3c77cbeb8ec59f2a3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!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>28.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 28. Monitoring Database Activity" /><link rel="next" href="monitoring-stats.html" title="28.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">28.1. Standard Unix Tools</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="monitoring.html" title="Chapter 28. Monitoring Database Activity">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="monitoring.html" title="Chapter 28. Monitoring Database Activity">Up</a></td><th width="60%" align="center">Chapter 28. Monitoring Database Activity</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="monitoring-stats.html" title="28.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">28.1. Standard Unix Tools</h2></div></div></div><a id="id-1.6.15.6.2" class="indexterm"></a><p>
   On most Unix platforms, <span class="productname">PostgreSQL</span> modifies its
   command title as reported by <code class="command">ps</code>, so that individual server
   processes can readily be identified.  A sample display is

</p><pre class="screen">
$ ps auxww | grep ^postgres
postgres  15551  0.0  0.1  57536  7132 pts/0    S    18:02   0:00 postgres -i
postgres  15554  0.0  0.0  57536  1184 ?        Ss   18:02   0:00 postgres: background writer
postgres  15555  0.0  0.0  57536   916 ?        Ss   18:02   0:00 postgres: checkpointer
postgres  15556  0.0  0.0  57536   916 ?        Ss   18:02   0:00 postgres: walwriter
postgres  15557  0.0  0.0  58504  2244 ?        Ss   18:02   0:00 postgres: autovacuum launcher
postgres  15582  0.0  0.0  58772  3080 ?        Ss   18:04   0:00 postgres: joe runbug 127.0.0.1 idle
postgres  15606  0.0  0.0  58772  3052 ?        Ss   18:07   0:00 postgres: tgl regression [local] SELECT waiting
postgres  15610  0.0  0.0  58772  3056 ?        Ss   18:07   0:00 postgres: tgl regression [local] idle in transaction
</pre><p>

   (The appropriate invocation of <code class="command">ps</code> varies across different
   platforms, as do the details of what is shown.  This example is from a
   recent Linux system.)  The first process listed here is the
   primary server process.  The command arguments
   shown for it are the same ones used when it was launched.  The next four
   processes are background worker processes automatically launched by the
   primary process.  (The <span class="quote"><span class="quote">autovacuum launcher</span></span> process will not
   be present if you have set the system not to run autovacuum.)
   Each of the remaining
   processes is a server process handling one client connection.  Each such
   process sets its command line display in the form

</p><pre class="screen">
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>
</pre><p>

  The user, database, and (client) host items remain the same for
  the life of the client connection, but the activity indicator changes.
  The activity can be <code class="literal">idle</code> (i.e., waiting for a client command),
  <code class="literal">idle in transaction</code> (waiting for client inside a <code class="command">BEGIN</code> block),
  or a command type name such as <code class="literal">SELECT</code>.  Also,
  <code class="literal">waiting</code> is appended if the server process is presently waiting
  on a lock held by another session.  In the above example we can infer
  that process 15606 is waiting for process 15610 to complete its transaction
  and thereby release some lock.  (Process 15610 must be the blocker, because
  there is no other active session.  In more complicated cases it would be
  necessary to look into the
  <a class="link" href="view-pg-locks.html" title="54.12. pg_locks"><code class="structname">pg_locks</code></a>
  system view to determine who is blocking whom.)
  </p><p>
   If <a class="xref" href="runtime-config-logging.html#GUC-CLUSTER-NAME">cluster_name</a> has been configured the
   cluster name will also be shown in <code class="command">ps</code> output:
</p><pre class="screen">
$ psql -c 'SHOW cluster_name'
 cluster_name
--------------
 server1
(1 row)

$ ps aux|grep server1
postgres   27093  0.0  0.0  30096  2752 ?        Ss   11:34   0:00 postgres: server1: background writer
...
</pre><p>
  </p><p>
   If you have turned off <a class="xref" href="runtime-config-logging.html#GUC-UPDATE-PROCESS-TITLE">update_process_title</a> then the
   activity indicator is not updated; the process title is set only once
   when a new process is launched.  On some platforms this saves a measurable
   amount of per-command overhead;  on others it's insignificant.
  </p><div class="tip"><h3 class="title">Tip</h3><p>
  <span class="productname">Solaris</span> requires special handling. You must
  use <code class="command">/usr/ucb/ps</code>, rather than
  <code class="command">/bin/ps</code>. You also must use two <code class="option">w</code>
  flags, not just one. In addition, your original invocation of the
  <code class="command">postgres</code> command must have a shorter
  <code class="command">ps</code> status display than that provided by each
  server process.  If you fail to do all three things, the <code class="command">ps</code>
  output for each server process will be the original <code class="command">postgres</code>
  command line.
  </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 28. Monitoring Database Activity">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="monitoring.html" title="Chapter 28. Monitoring Database Activity">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="monitoring-stats.html" title="28.2. The Cumulative Statistics System">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 28. Monitoring Database Activity </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 28.2. The Cumulative Statistics System</td></tr></table></div></body></html>