Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id B67829FB5FB for ; Tue, 20 Mar 2007 22:24:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 03021-02 for ; Tue, 20 Mar 2007 22:24:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from polaris.omc-international.com.au (unknown [203.49.69.44]) by postgresql.org (Postfix) with ESMTP id AF3D89FB5D3 for ; Tue, 20 Mar 2007 22:24:26 -0300 (ADT) Received: from [192.168.0.120] (peking.omc-international.com.au [192.168.0.120]) by polaris.omc-international.com.au (Postfix) with ESMTP id 3FB5D53918; Wed, 21 Mar 2007 12:24:06 +1100 (EST) Message-ID: <46008931.8060605@omc-international.com.au> Date: Wed, 21 Mar 2007 12:24:01 +1100 From: Joe Healy User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Dan Harris Cc: PostgreSQL Performance Subject: Re: Determining server load from client References: <460080A2.20800@drivefaster.net> In-Reply-To: <460080A2.20800@drivefaster.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/293 X-Sequence-Number: 23698 (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)