5 =head1 NAME $RCSfile: checkdns,v $
7 Check DNS by attempting to call gethostbyname of a well known host.
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Wed Aug 30 21:03:14 CDT 2006
27 $Date: 2011/04/15 15:05:16 $
33 Usage: checkdns [-u|sage] [-v|erbose] [-d|ebug]
34 [-s|leep <n>] [-l|ogpath <path>]
37 -u|sage Print this usage
38 -v|erbose: Verbose mode
39 -d|ebug: Emit debug information
41 -s|leep <n>: Set sleep period to <n> minutes (Default: 15 minutes)
42 -l|ogpath <path>: Put the log file in <path> (Default: /var/log)
46 This script will look at the security logfile for attempted breakins and then
47 use whois to report them to the upstream provider.
58 use lib "$FindBin::Bin/../lib";
64 my $VERSION = '$Revision: 1.6 $';
65 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
67 $0 = $FindBin::Script;
69 my $host = 'google.com';
71 my $initial_sleep = $sleep;
72 my $logpath = '/var/log';
80 my @ipaddrs = gethostbyname $host;
83 debug "Host: $host (ipaddrs empty)";
85 # Cut down sleep time to monitor this outage more closely but do not go
86 # below once a minute.
96 # Successful lookup - set $sleep to $initial_sleep
97 $sleep = $initial_sleep;
105 my $errors = $log->errors;
107 $log->msg ("$errors errors encountered since starting")
110 $log->msg ('Caught interrupt - shutting down');
117 usage => sub { Usage },
118 verbose => sub { set_verbose },
119 debug => sub { set_debug },
120 'sleep=i' => \$sleep,
121 'logpath=s' => \$logpath,
122 ) or Usage 'Invalid parameter';
124 # Need to reset $initial_sleep if it GetOptions changed it
125 $initial_sleep = $sleep;
128 $SIG {TERM} = \&Shutdown;
130 # Call sethostent so that gethostbyname is fresh everytime
135 timestamped => 'yes',
140 "Started $FindBin::Script $VERSION logging to $logpath/$FindBin::Script.log"
144 $log->msg ("Polling DNS on host $host every $sleep minutes");
146 $log->msg ("Polling DNS on host $host every minute");
153 my $status = CheckDNS $host;
156 $log->err ("Unable to resolve IP address for $host");
158 $log->msg ("Successfully resolved $host");
166 =head1 CONFIGURATION AND ENVIRONMENT
168 DEBUG: If set then $debug is set to this level.
170 VERBOSE: If set then $verbose is set to this level.
172 TRACE: If set then $trace is set to this level.
180 L<Getopt::Long|Getopt::Long>
182 =head2 ClearSCM Perl Modules
195 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
196 <a href="http://clearscm.com/php/scm_man.php?file=lib/Logger.pm">Logger</a><br>
197 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
202 =head1 BUGS AND LIMITATIONS
204 There are no known bugs in this script
206 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
208 =head1 LICENSE AND COPYRIGHT
210 Copyright (c) 2004, ClearSCM, Inc. All rights reserved.