Re: Determining server load from client - Mailing list pgsql-performance

From Craig A. James
Subject Re: Determining server load from client
Date
Msg-id 46008747.30206@modgraph-usa.com
Whole thread Raw
In response to Determining server load from client  (Dan Harris <fbsd@drivefaster.net>)
List 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.
Butnotice that you need "Untrusted Perl" to do this, so you can only do it on a system where you trust every
applicationthat 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

pgsql-performance by date:

Previous
From: Dan Harris
Date:
Subject: Determining server load from client
Next
From: Joe Healy
Date:
Subject: Re: Determining server load from client