#!/usr/bin/perl -w use strict; use DBI; my $dbhost = $ENV{'dbhost'} || '127.0.0.1'; my $dbname = $ENV{'dbname'} || 'template1'; my $dbuser = $ENV{'dbuser'} || 'postgres'; my $dbpass = $ENV{'dbpass'} || ''; if ($ARGV[0] && $ARGV[0] eq "config") { print <connect ($Con, $dbuser, $dbpass, {RaiseError =>1}) || die "Unable to access Database $dbname on host $dbhost as user $dbuser.\nError returned was: ". $DBI::errstr; my $sql="SELECT mode,COUNT(mode) FROM pg_locks GROUP BY mode ORDER BY mode;"; my $sth = $Dbh->prepare ($sql); $sth->execute (); my $locks = 0; my $exlocks = 0; while (my ($mode, $count) = $sth->fetchrow ()) { if ($mode =~ /exclusive/i) { $exlocks = $exlocks + $count; } $locks = $locks+$count; } print "locks.value $locks\n"; print "exlocks.value $exlocks\n"; }