DNSの監視

さくっとかいてみた。
まあ、これで十分でしょ。
MadEyeはここからどうぞ
http://code.mfac.jp/trac/browser/MadEye/

package MadEye::Plugin::Agent::DNS;
use strict;
use warnings;
use base qw/MadEye::Plugin/;
use Net::DNS;

sub is_alive {
    my ( $self, $context, $target ) = @_;

    $context->log( debug => "$target->{host} : $target->{type}" );

    my $res = Net::DNS::Resolver->new;
    $res->nameservers(@{$target->{nameservers}}) if $target->{nameservers};
    my $query = $res->query($target->{host},$target->{type});

    unless ($query) {
        return +{
            message => "$target->{host} : $target->{type} is no found. " . $res->errorstring,
            agent   => ref($self),
            target  => $target,
        };
    }
    return;
}

1;

__END__

=head1 SYNOPSIS

  - module: Agent::DNS
    config:
      nameservers:
        - ns1.example.jp
        - ns2.example.jp
      target:
        - host: example.jp
          type: A
        - host: example.jp
          type: NS