Re: number of connections to postmaster - Mailing list pgsql-general

From Hans-Juergen Schoenig
Subject Re: number of connections to postmaster
Date
Msg-id 3C740778.AC521FFE@cybertec.at
Whole thread Raw
In response to number of connections to postmaster  ("Percy" <percy_yip@yahoo.com>)
List 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


pgsql-general by date:

Previous
From: Björn Lundin
Date:
Subject: Re: access database conversion
Next
From: Hugo Coolens
Date:
Subject: batch file