pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Healy <joe@omc-international.com.au>
To: Dan Harris <fbsd@drivefaster.net>
Cc: PostgreSQL Performance <pgsql-performance@postgresql.org>
Subject: Re: Determining server load from client
Date: Wed, 21 Mar 2007 12:24:01 +1100
Message-ID: <46008931.8060605@omc-international.com.au> (raw)
In-Reply-To: <460080A2.20800@drivefaster.net>
References: <460080A2.20800@drivefaster.net>

(forgot to send to list)
Dan Harris wrote:
> architecture of the server hardware.  It would be very nice if I could 
> check the load of the server at certain intervals to throttle the 
> number of concurrent queries and mitigate load problems when other 
> processes might be already inducing a significant load.
>
> 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.  Even if it can't return the load average 
> proper, is there anything else in the pg_* tables that might give me a 
> clue how "busy" the server is for a period of time?



I have installed munin (http://munin.projects.linpro.no/) on a few 
systems. This lets you look at graphs of system resources/load etc. I 
have also added python scripts which do sample queries to let me know if 
performance/index size is changing dramatically. I have attached an 
example script.



Hope that helps,



Joe


------------------------------------------------------------------------

#! /usr/bin/python
import psycopg
import sys

def fixName(name):
    return name[:19]

if len(sys.argv) > 1 and sys.argv[1] == "config":
    print """graph_title Postgresql Index Sizes
graph_vlabel Mb"""

    con = psycopg.connect("host=xxx user=xxx dbname=xxx password=xxx")
    cur = con.cursor()
    
    cur.execute("select relname, relpages from pg_class where relowner > 10 and relkind='i' and relpages > 256 order by reltuples desc;")
    results = cur.fetchall()
    for name, pages in results:
        print "%s.label %s" % (fixName(name), name)

else:
    con = psycopg.connect("host=xxx user=xxx dbname=xxx password=xxx")
    cur = con.cursor()
    
    cur.execute("select relname, relpages from pg_class where relowner > 10 and relkind='i' and relpages > 256 order by reltuples desc;")
    results = cur.fetchall()
    
    for name, pages in results:
        print "%s.value %.2f" % (name[:19], pages*8.0/1024.0)




view thread (5+ messages)  latest in thread

Message-ID: <46008931.8060605@omc-international.com.au>
Permalink:  ../46008931.8060605@omc-international.com.au/
Also on:    postgresql.org/message-id/46008931.8060605@omc-international.com.au

 · 

reply

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: joe@omc-international.com.au, fbsd@drivefaster.net
  Subject: Re: Determining server load from client
  In-Reply-To: <46008931.8060605@omc-international.com.au>

* 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