Re: Determining server load from client

From: "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com>
To: Dan Harris <fbsd(at)drivefaster(dot)net>
Cc: PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Determining server load from client
Date: 2007-03-21 01:15:51
Message-ID: 46008747.30206@modgraph-usa.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Dan Harris wrote:
> I've found that it would be helpful to be able to tell how busy my
> dedicated PG server is ...
>
> I have seen some other nice back-end things exposed through PG functions
> ( e.g. database size on disk ) and wondered if there was anything
> applicable to this.

I'd write a simple pg-perl function to do this. You can access operating-system calls to find out the system's load. But notice that you need "Untrusted Perl" to do this, so you can only do it on a system where you trust every application that connects to your database. Something like this:

create or replace function get_stats()
returns text as '
open(STAT, "</proc/stat");
my @stats = <STAT>;
close STAT;
return join("", @stats);
' language plperlu;

See http://www.postgresql.org/docs/8.1/interactive/plperl-trusted.html

Craig

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jim Buttafuoco 2007-03-21 01:22:52 Re: Determining server load from client
Previous Message Dan Harris 2007-03-21 00:47:30 Determining server load from client