lib/App/MadEye/Plugin/Agent/SNMP/IPAddress.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 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 / 38 CC 2 SCAR 12.0
CC
2
Cov
0%
is_dead
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 package App::MadEye::Plugin::Agent::SNMP::IPAddress;
2 use strict;
3 use warnings;
4 use App::MadEye::Plugin::Agent::Base;
5 use App::MadEye::Util;
6  
7 my $oid_map = {
8 ipAdEntAddr => '.1.3.6.1.2.1.4.20.1.1'
9 };
10  
11 sub is_dead {
12 my ($self, $target) = @_;
13  
14 my $response = snmp_session(
15 $self,
16 $target->{host} => sub {
17 my $session = shift;
18  
19 $session->get_table(
20 -baseoid => $oid_map->{ipAdEntAddr},
21 ) or die "cannot get a $_ : " . $session->error
22 },
23 );
24  
25 my $expected = join ' ', sort { $a cmp $b } @{ $target->{ip} };
26 my $got = join ' ', sort { $a cmp $b } values %$response;
27  
28 context->log('debug' => "got: $got, expected: $expected");
29  
30 if ($got eq $expected) {
31 return; # alive
32 } else {
33 return "got: '$got' expected: '$expected'";
34 }
35 }
36  
37 1;
38 __END__