Re: number of connections to postmaster

From: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: number of connections to postmaster
Date: 2002-02-20 20:30:48
Message-ID: 3C740778.AC521FFE@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Check out techdocs.postgresql.org and download PL/Sh by Peter Eisentraut. You
can do the job with the help of an embedded Shell script.
As far as I know there is no other (easy way) of retrieving that information.

Try something like that:

CREATE OR REPLACE FUNCTION "backends_number"() RETURNS "text" AS '
#!/bin/sh
expr $(ps ax | egrep -e ''postgres:.*local'' | wc -l) - 1
' LANGUAGE 'plsh';

I have not tested this extensively but it should work.
Note: PL/Sh is not a trusted embedded languages (system calls are allowed) ->
use a separate database for that and don't use your production database
(security!!!!).

Hans

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Cindy 2002-02-20 20:53:20 documention on psql?
Previous Message paul simdars 2002-02-20 20:06:29 OID - insert statement