lib/App/MadEye/Plugin/Agent/DBI.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 40 CC 3 SCAR 18.4
CC
3
Cov
0%
is_dead
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.3
1 package App::MadEye::Plugin::Agent::DBI;
2 use strict;
3 use warnings;
4 use App::MadEye::Plugin::Agent::Base;
5  
6 use DBI;
7  
8 sub is_dead {
9 my ($self, $dsn) = @_;
10  
11 my $conf = $self->config->{config};
12 my $user = $conf->{user} or die "missing user";
13 my $password = $conf->{password} || '';
14  
15 my $dbh;
16 eval {
17 $dbh = DBI->connect(
18 $dsn,
19 $user,
20 $password,
21 {RaiseError => 1, AutoCommit => 1}
22 );
23 };
24  
25 if ($@) {
26 return $@;
27 } elsif (! $dbh->ping) {
28 return "DEAD";
29 } else {
30 return; # alive.
31 }
32 }
33  
34 1;
35 __END__