Обсуждение: Associating client PIDs with backend PIDs

Поиск
Список
Период
Сортировка

Associating client PIDs with backend PIDs

От
Rich Cullingford
Дата:
All,
This is a pretty obvious question, but I can't find an answer in the
standard docs/archive: if I have an installation in which there are a
number of long-running client processes interacting (one-on-one) with
backend processes, how do I find the associations? I can see the client
PIDs in an appropriate 'ps' (grepping on the client program name, for
example), and the backend PIDs in the standard queries or pgmonitor. But
I can't tell which goes with which (except by trying to infer the
association by looking at the query that's running -- assuming I can
catch it).

                   Thanks for any help,
                   Rich Cullingford
                   rculling@sysd.com


Re: Associating client PIDs with backend PIDs

От
Björn Lundin
Дата:
Rich Cullingford wrote:

> All,
> This is a pretty obvious question, but I can't find an answer in the
> standard docs/archive: if I have an installation in which there are a
> number of long-running client processes interacting (one-on-one) with
> backend processes, how do I find the associations? I can see the client
> PIDs in an appropriate 'ps' (grepping on the client program name, for
> example), and the backend PIDs in the standard queries or pgmonitor. But
> I can't tell which goes with which (except by trying to infer the
> association by looking at the query that's running -- assuming I can
> catch it).

if your client uses libpq, you could use

PQbackendPID Returns the process ID of the backend server handling this
connection.

int PQbackendPID(const PGconn *conn);

to save the backend's pid to a known file after you connected

/Björn

>
>                    Thanks for any help,
>                    Rich Cullingford
>                    rculling@sysd.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend


Re: Associating client PIDs with backend PIDs

От
"washirv"
Дата:
I use a separate command like lsof to map processes to tcp/unix ports on the client and server machines.



 --- On Mon 11/24, Rich Cullingford < rculling@sysd.com > wrote:
From: Rich Cullingford [mailto: rculling@sysd.com]
To: pgsql-admin@postgresql.org
Date: Mon, 24 Nov 2003 11:55:07 -0500
Subject: [ADMIN] Associating client PIDs with backend PIDs

All,<br>This is a pretty obvious question, but I can't find an answer in the <br>standard docs/archive: if I have an
installationin which there are a <br>number of long-running client processes interacting (one-on-one) with <br>backend
processes,how do I find the associations? I can see the client <br>PIDs in an appropriate 'ps' (grepping on the client
programname, for <br>example), and the backend PIDs in the standard queries or pgmonitor. But <br>I can't tell which
goeswith which (except by trying to infer the <br>association by looking at the query that's running -- assuming I can
<br>catchit).<br><br>                   Thanks for any help,<br>                   Rich Cullingford<br>
 rculling@sysd.com<br><br><br>---------------------------(end of broadcast)---------------------------<br>TIP 8:
explainanalyze is your friend<br> 

_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com