Обсуждение: Number of Connections

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

Number of Connections

От
"Steve McAtee"
Дата:
Hello,

I'm a bit new to postgres.  Is there anyway to tell the current number of
connections on a database or server?  I'm having a connection closing
problem and would like to debug it somehow.  I know on Sybase you can check
a sys table to determine this.  Not familiar with how to do this on
Postgres.

Please advise and thank you.



Re: Number of Connections

От
"Bryan White"
Дата:

> Hello,
>
> I'm a bit new to postgres.  Is there anyway to tell the current number of
> connections on a database or server?  I'm having a connection closing
> problem and would like to debug it somehow.  I know on Sybase you can
check
> a sys table to determine this.  Not familiar with how to do this on
> Postgres.

I use:
    ps ax | grep postgres | wc -l
Note the value is often one to high because is picks up the grep process.

Use
    ps ax | grep postgres
to look at the processes and see what IP are connected, what users, and what
the backend is doing (IDLE, SELECT, ..)



Re: Number of Connections

От
Neil Conway
Дата:
On Fri, Feb 16, 2001 at 02:09:42PM -0500, Bryan White wrote:
> I use:
>     ps ax | grep postgres | wc -l
> Note the value is often one to high because is picks up the grep process.

Why not just remove 'grep' - i.e

ps ax | grep postgres | grep -v grep | wc -l

HTH,

Neil

--
Neil Conway <neilconway@home.com>
Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc
Encrypted mail welcomed

Four stages of acceptance:
    i) this is worthless nonsense;
    ii) this is an interesting, but perverse, point of view;
    iii) this is true, but quite unimportant;
    iv) I always said so.
        -- J. B. S. Haldane in Journal of Genetics 58:464 (1963).

Re: Number of Connections

От
Tom Lane
Дата:
Neil Conway <nconway@klamath.dyndns.org> writes:
> On Fri, Feb 16, 2001 at 02:09:42PM -0500, Bryan White wrote:
>> ps ax | grep postgres | wc -l
>> Note the value is often one to high because is picks up the grep process.

> Why not just remove 'grep' - i.e
> ps ax | grep postgres | grep -v grep | wc -l

Actually this is a standard problem with a standard solution: use a
not-so-literal grep pattern, eg

    ps ax | grep '[p]ostgres' | wc -l

This pattern matches 'postgres' but not '[p]ostgres'.  Problem solved.

            regards, tom lane

Re: Number of Connections

От
"Tim Barnard"
Дата:
What's the purpose of the "grep -v grep" ?

Tim

----- Original Message -----
From: "Neil Conway" <nconway@klamath.dyndns.org>
To: "pgsql-general" <pgsql-general@postgreSQL.org>
Sent: Friday, February 16, 2001 12:05 PM
Subject: Re: [GENERAL] Number of Connections


> On Fri, Feb 16, 2001 at 02:09:42PM -0500, Bryan White wrote:
> > I use:
> >     ps ax | grep postgres | wc -l
> > Note the value is often one to high because is picks up the grep
process.
>
> Why not just remove 'grep' - i.e
>
> ps ax | grep postgres | grep -v grep | wc -l
>
> HTH,
>
> Neil
>
> --
> Neil Conway <neilconway@home.com>
> Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc
> Encrypted mail welcomed



Re: Number of Connections

От
John Burski
Дата:
The "-v" option tells grep to select everything EXCEPT the following
term.  Therefore, the "grep -v grep" section of the piped commands will
delete the "extra" line (the one generated by the "grep postgres"
command) that the ps command spits out prior to piping it into the "wc
-l" command.

Tim Barnard wrote:

> What's the purpose of the "grep -v grep" ?
>
> Tim
>
> ----- Original Message -----
> From: "Neil Conway" <nconway@klamath.dyndns.org>
> To: "pgsql-general" <pgsql-general@postgreSQL.org>
> Sent: Friday, February 16, 2001 12:05 PM
> Subject: Re: [GENERAL] Number of Connections
>
> > On Fri, Feb 16, 2001 at 02:09:42PM -0500, Bryan White wrote:
> > > I use:
> > >     ps ax | grep postgres | wc -l
> > > Note the value is often one to high because is picks up the grep
> process.
> >
> > Why not just remove 'grep' - i.e
> >
> > ps ax | grep postgres | grep -v grep | wc -l
> >
> > HTH,
> >
> > Neil
> >
> > --
> > Neil Conway <neilconway@home.com>
> > Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc
> > Encrypted mail welcomed

--
John Burski
Chief IT Cook and Bottlewasher
911 Emergency Products, St. Cloud, MN
(320) 656 0076       www.911ep.com

++++++++++++++++++++++++++++++++++
+ How's your cheese holding out? +
++++++++++++++++++++++++++++++++++




Re: Number of Connections

От
"Brett W. McCoy"
Дата:
On Fri, 16 Feb 2001, Tim Barnard wrote:

> What's the purpose of the "grep -v grep" ?

It ignores listing of grep in the output stream.

-- Brett
                                     http://www.chapelperilous.net/~bmccoy/
---------------------------------------------------------------------------
Q:    What do agnostic, insomniac dyslexics do at night?
A:    Stay awake and wonder if there's a dog.


Re: Number of Connections

От
"Tim Barnard"
Дата:
Thanks.

Tim

----- Original Message -----
From: "John Burski" <John.Burski@911ep.com>
To: "Tim Barnard" <tbarnard@povn.com>
Cc: "pgsql-general" <pgsql-general@postgresql.org>
Sent: Friday, February 16, 2001 2:47 PM
Subject: Re: [GENERAL] Number of Connections


> The "-v" option tells grep to select everything EXCEPT the following
> term.  Therefore, the "grep -v grep" section of the piped commands will
> delete the "extra" line (the one generated by the "grep postgres"
> command) that the ps command spits out prior to piping it into the "wc
> -l" command.
>
> Tim Barnard wrote:
>
> > What's the purpose of the "grep -v grep" ?
> >
> > Tim
> >