[Collab-qa-commits] r935 - udd/src

neronus-guest at alioth.debian.org neronus-guest at alioth.debian.org
Sat Jul 26 12:46:08 UTC 2008


Author: neronus-guest
Date: 2008-07-26 12:46:07 +0000 (Sat, 26 Jul 2008)
New Revision: 935

Added:
   udd/src/check-size.pl
Log:
Added script to check database size


Added: udd/src/check-size.pl
===================================================================
--- udd/src/check-size.pl	                        (rev 0)
+++ udd/src/check-size.pl	2008-07-26 12:46:07 UTC (rev 935)
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+# Last-Modified: <Sat Jul 26 12:46:51 2008>
+
+# This script is part of the Debian Ultimate Database Project
+# It's used to check the size of the postgres database in use
+# synopsis: check-size.pl <configuration file>
+
+use strict;
+use warnings;
+
+use DBI;
+use YAML::Syck;
+
+$YAML::Syck::ImplicitTyping = 1;
+
+defined $ARGV[0] or die "Usage: $0 <config-file>";
+
+my $config = LoadFile($ARGV[0]);
+
+my $dbname = $config->{general}->{dbname};
+my $dbh = DBI->connect("dbi:Pg:dbname=$dbname") or die "Couldn't connect to database: $!";
+
+my $sth = $dbh->prepare("SELECT pg_database.datname,\
+	pg_size_pretty(pg_database_size(pg_database.datname)) AS size\
+	FROM pg_database;");
+$sth->execute() or die $!;
+
+while(my ($dbname, $dbsize) = $sth->fetchrow_array()) {
+	if($dbname eq $config->{general}->{dbname}) {
+		print "$dbsize\n";
+		exit 0;
+	}
+}
+
+print STDERR "Couldn't find database in response\n";
+exit 1;


Property changes on: udd/src/check-size.pl
___________________________________________________________________
Name: svn:executable
   + *




More information about the Collab-qa-commits mailing list