#!/usr/bin/perl -w

use strict;
use DBI;

my $host = shift @ARGV || '';
$host = ";host=$host" if ($host);
my $user = shift @ARGV || "dpavlin";
my $pass = shift @ARGV || "";

my $sql = "select sum(numbackends),sum(xact_commit),sum(xact_rollback),sum(blks_read),sum(blks_hit) from pg_stat_database";

my $dbh = DBI->connect("DBI:Pg:dbname=template1$host",$user,$pass) || die $DBI::errstr;
my $sth=$dbh->prepare($sql);

if ($sth->execute()) {
	print join("\n",$sth->fetchrow_array()),"\n";
}

undef $sth;
$dbh->disconnect();
