mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
die commands if no DB connection can be made
graceful die script if DB connection cannot be created. Also for prepare & execute command
This commit is contained in:
parent
647632f7af
commit
6facd3c331
1 changed files with 6 additions and 3 deletions
|
@ -157,13 +157,16 @@ if (defined($ARGV[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
# connect to data
|
# connect to data
|
||||||
my $dbh = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host;port=$db_port", $db_user, $db_pass);
|
my $dbh = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host;port=$db_port", $db_user, $db_pass)
|
||||||
|
or die ("Cannot connect to database");
|
||||||
# go trough each set and get the data
|
# go trough each set and get the data
|
||||||
foreach my $get ('pools', 'stats')
|
foreach my $get ('pools', 'stats')
|
||||||
{
|
{
|
||||||
# prep and execute the show query
|
# prep and execute the show query
|
||||||
my $pre = $dbh->prepare("SHOW $get");
|
my $pre = $dbh->prepare("SHOW $get")
|
||||||
$pre->execute();
|
or die ("Cannot prepare query");
|
||||||
|
$pre->execute()
|
||||||
|
or die ("Cannot execute statement")
|
||||||
while (@data = $pre->fetchrow)
|
while (@data = $pre->fetchrow)
|
||||||
{
|
{
|
||||||
# first defines the pool
|
# first defines the pool
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue