Re: get number and names of processes connected to postgresql - Mailing list pgsql-general

From Marti Raudsepp
Subject Re: get number and names of processes connected to postgresql
Date
Msg-id CABRT9RAhkBNppZUK7yCQqQSdEezTY73H4D3xzjciaaKB4kM=aw@mail.gmail.com
Whole thread Raw
In response to get number and names of processes connected to postgresql  (Gregg Jaskiewicz <gryzman@gmail.com>)
Responses Re: get number and names of processes connected to postgresql  (Gregg Jaskiewicz <gryzman@gmail.com>)
List pgsql-general
On Fri, Sep 23, 2011 at 13:34, Gregg Jaskiewicz <gryzman@gmail.com> wrote:
> Basically, I got bunch of local processes connecting to postgresql,
> need to aggregate some sort of report about number of connections and
> its origin every so often.

The pg_stat_activity system view gives you the database name (datname)
and user name (usename) they're connected with. client_addr tells you
what IP address they're connecting from.

Generally you would use different usernames and databases for
different applications, so that should give you a good enough picture?
You can even run aggregate queries over this view so such a report is
just a matter of writing SQL :)

PostgreSQL 9.0 also adds a "application_name" variable that each
connection can set that's visible in pg_stat_activity.

Regards,
Marti

pgsql-general by date:

Previous
From: Eduardo Morras
Date:
Subject: Re: looking for a faster way to do that
Next
From: Roger Niederland
Date:
Subject: Re: pg_dump compress