Re: If gethostbyname fails it never recovers



"Andrew" == Andrew DeFaria <Andrew@xxxxxxxxxxx> writes:

Andrew> So I tried writing a script that would monitor this. The script calls
Andrew> gethostbyname for google.com every 15 minutes and logs the status. When
Andrew> gethostbyname fails however it never comes back. My ISP and internet
Andrew> connection may come back and nslookup at the command line will work fine. But
Andrew> my script will report failure at the next and following 15 minute
Andrew> intervals. This is very unexpected. What am I doing wrong and is there a way
Andrew> to "reset" things so that it will start working again.

Andrew> Here's a snippet:

Andrew> sub CheckDNS {
Andrew> my $host = shift;

Andrew> my @ipaddrs = gethostbyname $host;
Andrew> my $status = $?;

Andrew> if ($status ne 0 and $debug) {
Andrew> debug "Host: $host ($status)";
Andrew> } # if

Andrew> return $status
Andrew> } # CheckDNS

Andrew> CheckDNS is called every 15 minutes with "google.com" as a parm. When a
Andrew> failure happens $status = 2 and remains = 2 forever.

$? is not set for a gethostbyname failure. In fact, I'm not sure
anything is actually set.

And now a word from our Usenet manager...

If you can see this message, you are reading a group that is not
officially carried, and therefore doesn't get the propogation or
readership that the official comp.lang.perl.misc group gets.

What this means TO YOU is that your question won't be answered
to the same expert level that an official group will get. You'll
get answers that are wrong (and not noticed to be wrong), or no
answer at all.

STOP POSTING HERE. POST TO COMP.LANG.PERL.MISC

And send email to your news server administrator to PLEASE DELETE THIS
GROUP.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxxxxxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: "Dynamic" script of some sort needed for mp3 linking
    ... This would be easily created with a dynamic server side language such ... I am sure there is a free script out there that would do this for you, ... tro to Google "php open source file directory" or similar and I am sure ... This new text "Andrew" would also need to be ...
    (alt.html)
  • Re: Row size and DBCC SHOWCONTIG
    ... Sorry but I didn't even see the script the first time. ... Andrew J. Kelly SQL MVP ... > It behaves the same way with or without a clustered index. ... >> Andrew J. Kelly SQL MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Database Backup
    ... Don't use EM, use a script instead. ... The restore syntax is ... Andrew J. Kelly SQL MVP ... >> Andrew J. Kelly SQL MVP ...
    (microsoft.public.sqlserver.server)
  • RE: WPC11 ver 3 or bust...
    ... > Andrew L. Gould ... > I'm using the same card on 5.2.1 Release on a Dell Inspiron ... > If you try the script above and still get the error message, ... > Andrew Gould ...
    (freebsd-questions)
  • Re: combinations script - out of memory - optimization?
    ... Andrew wrote: ... a while ago i obtained a script that computes all unique subsets of a ... The script works fine when N<14, but past that value my server gives up ... returns an array of strings, ...
    (comp.lang.perl.misc)