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

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 47 CC 4 SCAR 24.0
CC
4
Cov
0%
is_dead
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 11.0
1 package App::MadEye::Plugin::Agent::Mogilefsd;
2 use strict;
3 use warnings;
4 use App::MadEye::Plugin::Agent::Base;
5  
6 use MogileFS::Admin;
7  
8 sub is_dead {
9 my ($self, $host) = @_;
10  
11 my $conf = $self->config->{config};
12 my $retry = $conf->{retry} || 3;
13  
14 my $mogadm = MogileFS::Admin->new(hosts => [$host]);
15  
16 my @hosts;
17 my $error;
18 for (my $i=0; $i<$retry; $i++) {
19 eval {
20 @hosts = $mogadm->get_hosts();
21 };
22 $error = $@;
23 last unless $error;
24 }
25  
26 if ($error) {
27 return "ERROR: $@";
28 }
29 elsif (scalar(@hosts) == 0) {
30 return "THIS TRACKER HAS NO STORE";
31 }
32 else {
33 return; # alive!
34 }
35 }
36  
37 1;
38 __END__