Search Postgresql Archives

Re: identify database process given client process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joey K. wrote:
On Mon, Mar 17, 2008 at 6:58 AM, hogcia <hogcia@xxxxxxxxx> wrote:

Hi,
I have to find a Postgres database process pid (or other
identification) for a given client process pid. Or client processes
for a database process. How are they connected? I was suggested maybe
netstat could give me the answer and I think those are two pf_unix
processes. But maybe there are some PostgreSQL functions that do this?
How should I approach this topic?
Thanks in advance,


Try

select pg_stat_activity;


Joey


That would be select * from pg_stat_activity;

The columns that interest you would be datname,procpid,usename and client_addr


The other way would be using ps (for a *nix server)

Depending on your system something similar to ps aux will give the process details so the command column will give you something like -

postgres: mydbuser mydbname 192.168.0.3(49438) idle

which is the info you are after - pgsql is the dbusername, postgres is the db they are connected to then the ip address and port they are connecting from. The idle at the end will be replaced with the query they are running.



--

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux