Search
j0ke.net Open Build Service
>
Projects
>
server:monitoring
:
icinga
:
production
>
nagios-plugins-dns
> check_resolver.pl
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File check_resolver.pl of Package nagios-plugins-dns
#!/usr/bin/perl -w require 5.006; use strict; use Net::DNS; #$ENV{PATH} = "/bin"; #$ENV{BASH_ENV} = ""; #$|=1; my $host = shift || &usage; my $domainfile = "/etc/nagios/domains.list"; # get some data to do our lookups open(DOMAIN,"<$domainfile") or die "Error Opening $domainfile File!\n"; my @data = <DOMAIN>; close(DOMAIN); my $randomline = int(rand @data); chomp $data[$randomline]; my $res = Net::DNS::Resolver->new( nameservers => [$host], recurse => 0, dnsrch => 0, debug => 0, ); my $query = $res->search("$data[$randomline]", 'A'); if ($query) { print "$data[$randomline] is "; foreach my $rr ($query->answer) { next unless $rr->type eq "A"; print $rr->address, " "; } print "\n"; } else { # really wrong. Needs to generate output # return ("DNS server could not resolve $data[$randomline]"); } sub usage { print "Minimum arguments not supplied!\n"; exit -1; }