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';
125 $SIG {TERM} = \&Shutdown;
127 # Call sethostent so that gethostbyname is fresh everytime
132 timestamped => 'yes',
137 "Started $FindBin::Script $VERSION logging to $logpath/$FindBin::Script.log"
140 $log->msg ("Polling DNS on host $host every $sleep minutes");
146 my $status = CheckDNS $host;
149 $log->err ("Unable to resolve IP address for $host");
151 $log->msg ("Successfully resolved $host");
159 =head1 CONFIGURATION AND ENVIRONMENT
161 DEBUG: If set then $debug is set to this level.
163 VERBOSE: If set then $verbose is set to this level.
165 TRACE: If set then $trace is set to this level.
173 L<Getopt::Long|Getopt::Long>
175 =head2 ClearSCM Perl Modules
188 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
189 <a href="http://clearscm.com/php/scm_man.php?file=lib/Logger.pm">Logger</a><br>
190 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
195 =head1 BUGS AND LIMITATIONS
197 There are no known bugs in this script
199 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
201 =head1 LICENSE AND COPYRIGHT
203 Copyright (c) 2004, ClearSCM, Inc. All rights reserved.