If gethostbyname fails it never recovers



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.

--

Andrew DeFaria <http://defaria.com>
Dain bramaged.


Relevant Pages

  • If gethostbyname fails it never recovers
    ... The script calls gethostbyname for google.com every 15 minutes and logs the status. ... My ISP and internet connection may come back and nslookup at the command line will work fine. ... sub CheckDNS { ...
    (comp.lang.perl.misc)
  • Re: How dial outside of KDE/Gnome ???
    ... ]>>> I can dial my ISP nicely from KDE or Gnome. ... Worked fine in command line driven mode (even script ...
    (comp.os.linux.networking)
  • Re: one script for pap/chap and manual authentication
    ... >Well I used your script to deal with a ISP here (which I know ... I've seen used to set up logging in windoze. ... and ignore the text based login. ... know what to do once they sent a login/password, unless the ISP auto ...
    (comp.os.linux.networking)
  • Re: How to schedule script without cron?
    ... > then fire the script when the file count reaches a certain number, ... that is in a loop: ... I use DDNS for inbound POP SMTP and my ISP for outbound. ...
    (comp.lang.php)
  • Re: A webhosting script?
    ... Subject: A webhosting script? ... I am the top technical dog at a regional ISP here. ... on PHP that yakks to a mysql database. ... customers listed in the accounting system that aren't in the actual ...
    (freebsd-questions)