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

From Joe Healy
Subject Re: Determining server load from client
Date
Msg-id 46008931.8060605@omc-international.com.au
Whole thread Raw
In response to Determining server load from client  (Dan Harris <fbsd@drivefaster.net>)
Responses OT: Munin (was Re: Determining server load from client)
List pgsql-performance
(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
reltuplesdesc;") 
    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
reltuplesdesc;") 
    results = cur.fetchall()

    for name, pages in results:
        print "%s.value %.2f" % (name[:19], pages*8.0/1024.0)


pgsql-performance by date:

Previous
From: "Craig A. James"
Date:
Subject: Re: Determining server load from client
Next
From: Dan Harris
Date:
Subject: Re: Determining server load from client