From: Craig A. James <cjames@modgraph-usa.com>
To: Dan Harris <fbsd@drivefaster.net>
Cc: PostgreSQL Performance <pgsql-performance@postgresql.org>
Subject: Re: Determining server load from client
Date: Tue, 20 Mar 2007 17:15:51 -0800
Message-ID: <46008747.30206@modgraph-usa.com> (raw)
In-Reply-To: <460080A2.20800@drivefaster.net>
References: <460080A2.20800@drivefaster.net>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: cjames@modgraph-usa.com, fbsd@drivefaster.net
Subject: Re: Determining server load from client
In-Reply-To: <46008747.30206@modgraph-usa.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox