Re: OT: Munin (was Re: Determining server load from client) - Mailing list pgsql-performance

From Erik Jones
Subject Re: OT: Munin (was Re: Determining server load from client)
Date
Msg-id 2B568D22-BDCC-40B7-B27D-0F47216094F2@myemma.com
Whole thread Raw
In response to Re: OT: Munin (was Re: Determining server load from client)  (Tobias Brox <tobias@nordicbet.com>)
Responses Re: OT: Munin (was Re: Determining server load from client)
List pgsql-performance

On Mar 21, 2007, at 5:13 AM, Tobias Brox wrote:

I have my postgres munin monitoring script at
.txt to make the local apache happy).

I would like to see what others have done as well.

I use cacti (http://cacti.net) which does the same thing that munin does but in php instead.  Here's what I use to db stats to it (again, php):

You basically call the script with the database name and the stat you want.  I have the active_queries stat set up as a gauge in cacti and the others as counters:

if(!isset($argv[1])) {    echo "DB name argument required!\n";    exit();
}

$stats = array('xact_commit', 'xact_rollback', 'blks_read', 'blks_hit', 'active_queries');
if(!isset($argv[2]) || !in_array($argv[2], $stats)) {    echo "Invalid stat arg!: {$argv[2]}";
    exit();
}
require_once('DB.php');

$db_name = $argv[1];
if(DB::isError($db = DB::connect("pgsql://user@host:5432/$db_name"))) {
    exit();
}

if($argv[2] == 'active_queries') {
    $actives_sql = "SELECT COUNT(*)
                    FROM pg_stat_activity
                    WHERE current_query NOT ILIKE '<idle>'
                        AND now() - query_start > '1 second';";
    if(DB::isError($db_stat = $db->getOne($actives_sql))) {
        exit();
    }
    echo "$db_stat\n";
    exit();
}

$db_stat_sql = "SELECT {$argv[2]}
                 FROM pg_stat_database
                 WHERE datname='$db_name';";
if(DB::isError($db_stat = $db->getOne($db_stat_sql))) {
    exit();
}

echo "$db_stat\n";


erik jones <erik@myemma.com>
software developer
615-296-0838
emma(r)



pgsql-performance by date:

Previous
From: Richard Huxton
Date:
Subject: Re: OT: Munin (was Re: Determining server load from client)
Next
From: Tobias Brox
Date:
Subject: Re: OT: Munin (was Re: Determining server load from client)