Hi All,

I have this script:
#!/usr/bin/perl use IO::Socket::INET; $ns1dns = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 53, Proto => 'tcp'); $ns2dns = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 53, Proto => 'tcp'); $ns3dns = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 53, Proto => 'tcp'); $ns4dns = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 53, Proto => 'tcp'); $mx1pop3 = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 995, Proto => 'tcp'); $mx1imap = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 993, Proto => 'tcp'); $mx1smtp = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 25, Proto => 'tcp'); $mx1web = IO::Socket::INET->new( PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 80, Proto => 'tcp'); print "Content-type: text/html\n\n"; # Web Services if ($mx1web) { print "<IMG SRC='http://www.xxx.com/images/up.gif' WIDTH=38 HEIGHT=2 +1>"; } else { print "<IMG SRC='http://www.xxx.com/images/down.gif' WIDTH=38 HEIGHT +=21>"; } print "<br>"; # DNS Services if ($ns1dns|$ns2dns|ns3dns|ns4dns) { print "<IMG SRC='http://www.xxx.com/images/up.gif' WIDTH=38 HEIGHT=2 +1>"; } else { print "<IMG SRC='http://www.xxx.com/images/down.gif' WIDTH=38 HEIGHT +=21>"; } print "<br>"; #Mail Services if ($mx1pop3|$mx1imap|mx1smtp) { print "<IMG SRC='http://www.xxx.com/images/up.gif' WIDTH=38 HEIGHT=2 +1>"; } else { print "<IMG SRC='http://www.xxx.com/images/down.gif' WIDTH=38 HEIGHT +=21>"; } print "<br>";
It is supposed to display the down gif when any one of the variables in brackets i.e ($mx1pop|$mx1imap) is not responding, but if i take one of the servers down, it waits for ages before still displaying the up gif.

Why does it show the up.gif file even when a server is down, and also is there anyway to set a maximum timeout for the servers, as if i take one down it can take up to 30 seconds before it returns the results.

Thanks

In reply to Whats wrong with this? & Timeouts by lostperls

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.