| 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__ |