lib/App/MadEye/Plugin/Agent/TheSchwartz/Job.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 46 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::TheSchwartz::Job;
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 my $threshold = $conf->{threshold} or die "missing threshold";
15  
16 my $dbh;
17 eval {
18 $dbh = DBI->connect(
19 $dsn,
20 $user,
21 $password,
22 {RaiseError => 1, AutoCommit => 1}
23 );
24 };
25  
26 if ($@) {
27 return $@;
28 } else {
29 my ($cnt) = $dbh->selectrow_array(q{select count(*) from job});
30 if ($cnt > $threshold) {
31 return "job count: $cnt";
32 } else {
33 return; # alive
34 }
35 }
36 }
37  
38 1;
39 __END__