Révision 6facd3c3
die commands if no DB connection can be made
graceful die script if DB connection cannot be created. Also for
prepare & execute command
| plugins/postgresql/pgbouncer_ | ||
|---|---|---|
| 157 | 157 |
} |
| 158 | 158 |
|
| 159 | 159 |
# connect to data |
| 160 |
my $dbh = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host;port=$db_port", $db_user, $db_pass);
|
|
| 160 |
my $dbh = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host;port=$db_port", $db_user, $db_pass)
|
|
| 161 |
or die ("Cannot connect to database");
|
|
| 161 | 162 |
# go trough each set and get the data |
| 162 | 163 |
foreach my $get ('pools', 'stats')
|
| 163 | 164 |
{
|
| 164 | 165 |
# prep and execute the show query |
| 165 |
my $pre = $dbh->prepare("SHOW $get");
|
|
| 166 |
$pre->execute(); |
|
| 166 |
my $pre = $dbh->prepare("SHOW $get")
|
|
| 167 |
or die ("Cannot prepare query");
|
|
| 168 |
$pre->execute() |
|
| 169 |
or die ("Cannot execute statement")
|
|
| 167 | 170 |
while (@data = $pre->fetchrow) |
| 168 | 171 |
{
|
| 169 | 172 |
# first defines the pool |
Formats disponibles : Unified diff