| 1 | package App::MadEye::Plugin::Agent::SNMP::Process; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use App::MadEye::Plugin::Agent::Base; | ||
| 5 | use App::MadEye::Util; | ||
| 6 | use List::Util qw/first/; | ||
| 7 | |||
| 8 | my $hrSWRunPath = '.1.3.6.1.2.1.25.4.2.1.4'; | ||
| 9 | |||
| 10 | sub is_dead { | ||
| 11 | my ($self, $host) = @_; | ||
| 12 | |||
| 13 | my $process = $self->config->{config}->{process} or die "missing process"; | ||
| 14 | |||
| 15 | my $response = snmp_session( | ||
| 16 | $self, | ||
| 17 | $host => sub { | ||
| 18 | my $session = shift; | ||
| 19 | my $response = $session->get_table( | ||
| 20 | -baseoid => $hrSWRunPath, | ||
| 21 | ) or die "cannot get a $_ : " . $session->error; | ||
| 22 | return $response; | ||
| 23 | } | ||
| 24 | ); | ||
| 25 | |||
| 26 | if (first { $_ eq $process } values %$response) { | ||
| 27 | return; # alive | ||
| 28 | } else { | ||
| 29 | return "404 $process not found"; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | 1; | ||
| 34 | __END__ |