/[cricket]/parse_pg_stat.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /parse_pg_stat.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri Aug 8 10:49:52 2003 UTC (15 years, 10 months ago) by dpavlin
Branch: MAIN
Changes since 1.1: +3 -2 lines
File MIME type: text/plain
allows to specify user and password in configuration (and not in script)

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 my $user = shift @ARGV || "dpavlin";
9 my $pass = shift @ARGV || "";
10
11 my $sql = "select sum(numbackends),sum(xact_commit),sum(xact_rollback),sum(blks_read),sum(blks_hit) from pg_stat_database";
12
13 my $dbh = DBI->connect("DBI:Pg:dbname=template1$host",$user,$pass) || die $DBI::errstr;
14 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();

  ViewVC Help
Powered by ViewVC 1.1.26