The patch below fixes imap.monitor so it reports the usual summary
followed by details, and clarifies the error messages for a couple
of situations.

        -- Ed



--- imap.monitor        2001/10/10 15:11:26     1.1
+++ imap.monitor        2001/10/10 15:10:20
@@ -42,6 +42,7 @@
 $TIMEOUT = $opt_t || 30;
 
 @failures = ();
+@details=   ();
 
 foreach $host (@ARGV) {
 
@@ -55,6 +56,7 @@
 }
 
 print join (" ", sort @failures), "\n";
+print sort @details if (scalar @details) > 0;
 
 exit 1;
 
@@ -105,7 +107,7 @@
     };
 
     if ($EVAL_ERROR and ($EVAL_ERROR =~ /^Timeout Alarm/)) {
-       print "**** Time Out\n";
+       push(@details, "$host: timeout($TIMEOUT)\n");
        return 0;
     }
     return $ServerOK;
@@ -126,12 +128,19 @@
     ($name, $aliases, $Port) = getservbyname($Port, 'tcp') unless $Port =~ /^\d+$/;
     ($name, $aliases, $type, $len, $ThisAddr) = gethostbyname($OurHostname);
     ($name, $aliases, $type, $len, $OtherHostAddr) = gethostbyname($OtherHostname);
+       if (!defined $OtherHostAddr)
+       {
+               push (@details, "$host: cannot resolve hostname\n");
+               return undef
+       }
 
     my $that = sockaddr_in ($Port, $OtherHostAddr);
 
-    $result = socket(S, &PF_INET, &SOCK_STREAM, $proto) || return undef;
-
-    $result = connect(S, $that) || return undef;
+    if (! ($result = socket(S, &PF_INET, &SOCK_STREAM, $proto)) ||
+       (! ($result = connect(S, $that))) )
+       {
+        push (@details, "$host: $!\n");  return undef;
+       }
 
     select(S); $| = 1; select(STDOUT);      # set S to be un-buffered
     return 1;                               # success

Reply via email to