1 |
dpavlin |
1.1 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use DBI; |
5 |
|
|
|
6 |
|
|
my $host = shift @ARGV || ''; |
7 |
|
|
$host = ";host=$host" if ($host); |
8 |
dpavlin |
1.2 |
my $user = shift @ARGV || "dpavlin"; |
9 |
|
|
my $pass = shift @ARGV || ""; |
10 |
dpavlin |
1.1 |
|
11 |
|
|
my $sql = "select sum(numbackends),sum(xact_commit),sum(xact_rollback),sum(blks_read),sum(blks_hit) from pg_stat_database"; |
12 |
|
|
|
13 |
dpavlin |
1.2 |
my $dbh = DBI->connect("DBI:Pg:dbname=template1$host",$user,$pass) || die $DBI::errstr; |
14 |
dpavlin |
1.1 |
my $sth=$dbh->prepare($sql); |
15 |
|
|
|
16 |
|
|
if ($sth->execute()) { |
17 |
|
|
print join("\n",$sth->fetchrow_array()),"\n"; |
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
undef $sth; |
21 |
|
|
$dbh->disconnect(); |