--- anon_ftp.monitor 2002/09/02 11:57:03 1.1 +++ anon_ftp.monitor 2002/09/02 13:57:13 1.2 @@ -3,9 +3,14 @@ # Use try to connect to a FTP server using Net::FTP, login as # anonymous and issue PWD. # +# Since anonymous ftp servers can be quite busy I suggest that you +# enter more than one anonymous ftp server and use option -o. That will +# return success if ANY OF SERVERS are available -- that way you can +# test if you can connect to ANY ftp server outside. +# # For use with "mon". # -# Arguments are "-p port -t timeout host [host...]" +# Arguments are "[-p port] [-t timeout] [-o] host [host...]" # # 2002-09-02 Dobrica Pavlinusic # @@ -13,7 +18,7 @@ use Getopt::Std; use Net::FTP; -getopts ("p:t:"); +getopts ("p:t:o"); $PORT = $opt_p || 21; $TIMEOUT = $opt_t || 30; @@ -24,6 +29,8 @@ my $result = check_anon_ftp($host); if ($result) { $bad{$host} = $result; + } else { + $good{$host} = "ok"; } } @@ -37,6 +44,11 @@ print "HOST $h: " . $bad{$h}, "\n"; } +if ($opt_o && keys %good > 0) { + # one host is o.k., don't report warning + exit 0; +} + exit 1; sub check_anon_ftp {