A
Andrew DeFaria
I've been having problems with my ISP. One way it seems to manifest
itself is that I can not reach or contact my ISP's DNS servers. IOW a
simply nslookup google.com will fail.
So I tried writing a script that would monitor this. The script calls
gethostbyname for google.com every 15 minutes and logs the status. When
gethostbyname fails however it never comes back. My ISP and internet
connection may come back and nslookup at the command line will work
fine. But my script will report failure at the next and following 15
minute intervals. This is very unexpected. What am I doing wrong and is
there a way to "reset" things so that it will start working again.
Here's a snippet:
sub CheckDNS {
my $host = shift;
my @ipaddrs = gethostbyname $host;
my $status = $?;
if ($status ne 0 and $debug) {
debug "Host: $host ($status)";
} # if
return $status
} # CheckDNS
CheckDNS is called every 15 minutes with "google.com" as a parm. When a
failure happens $status = 2 and remains = 2 forever.
itself is that I can not reach or contact my ISP's DNS servers. IOW a
simply nslookup google.com will fail.
So I tried writing a script that would monitor this. The script calls
gethostbyname for google.com every 15 minutes and logs the status. When
gethostbyname fails however it never comes back. My ISP and internet
connection may come back and nslookup at the command line will work
fine. But my script will report failure at the next and following 15
minute intervals. This is very unexpected. What am I doing wrong and is
there a way to "reset" things so that it will start working again.
Here's a snippet:
sub CheckDNS {
my $host = shift;
my @ipaddrs = gethostbyname $host;
my $status = $?;
if ($status ne 0 and $debug) {
debug "Host: $host ($status)";
} # if
return $status
} # CheckDNS
CheckDNS is called every 15 minutes with "google.com" as a parm. When a
failure happens $status = 2 and remains = 2 forever.