aboutsummaryrefslogtreecommitdiff
path: root/contrib/check_dns_random.pl
blob: 787d464413bce1adec9c5641fb3023e4a50ffe43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl
# ------------------------------------------------------------------------------
# File Name:            check_dns_random.pl
# Author:               Richard Mayhew - South Africa
# Date:                 2000/01/26
# Version:              1.0
# Description:          This script will check to see if dns resolves hosts
#                       randomly from a list using the check_dns plugin. 
# Email:                netsaint@splash.co.za
# ------------------------------------------------------------------------------
# Copyright 1999 (c) Richard Mayhew
# Credits go to Ethan Galstad for coding Nagios
# If any changes are made to this script, please mail me a copy of the
# changes :)
# License GPL
# ------------------------------------------------------------------------------
# Date          Author          Reason
# ----          ------          ------
# 1999/09/26    RM              Creation
# ------------------------------------------------------------------------------

# -----------------------------------------------------------------[ Require ]--
require 5.004;

# --------------------------------------------------------------------[ Uses ]--
use Socket;
use strict;

# --------------------------------------------------------------[ Enviroment ]--
$ENV{PATH} = "/bin";
$ENV{BASH_ENV} = "";
$|=1;

my $host = shift || &usage;

my $domainfile = "/usr/local/nagios/etc/domains.list";
my $wc = `/usr/bin/wc -l $domainfile`;
my $check = "/usr/local/nagios/libexec/check_dns";
my $x = 0;
my $srv_file = "";
my $z = "";
my $y = "";

open(DOMAIN,"<$domainfile") or die "Error Opening $domainfile File!\n";
        while (<DOMAIN>) {
          $srv_file .= $_;
}
        close(DOMAIN);
                my @data = split(/\n/,$srv_file);

chomp $wc;
$wc =~ s/ //g;
$wc =~ s/domains//g;

$x = rand $wc;
($z,$y) = split(/\./,$x);

print `$check $data[$z] $host`;



sub usage
{
        print "Minimum arguments not supplied!\n";
        print "\n";
        print "Perl Check Random DNS plugin for Nagios\n";
        print "Copyright (c) 2000 Richard Mayhew\n";
        print "\n";
        print "Usage: check_dns_random.pl <host>\n";
        print "\n";
        print "<host> = DNS server you would like to query.\n";
        exit -1;

}