/[mon-modules]/anon_ftp.monitor
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /anon_ftp.monitor

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Mon Sep 2 11:57:03 2002 UTC revision 1.2 by dpavlin, Mon Sep 2 13:57:13 2002 UTC
# Line 3  Line 3 
3  # Use try to connect to a FTP server using Net::FTP, login as  # Use try to connect to a FTP server using Net::FTP, login as
4  # anonymous and issue PWD.  # anonymous and issue PWD.
5  #  #
6    # Since anonymous ftp servers can be quite busy I suggest that you
7    # enter more than one anonymous ftp server and use option -o. That will
8    # return success if ANY OF SERVERS are available -- that way you can
9    # test if you can connect to ANY ftp server outside.
10    #
11  # For use with "mon".  # For use with "mon".
12  #  #
13  # Arguments are "-p port -t timeout host [host...]"  # Arguments are "[-p port] [-t timeout] [-o] host [host...]"
14  #  #
15  # 2002-09-02 Dobrica Pavlinusic <dpavlin@rot13.org>  # 2002-09-02 Dobrica Pavlinusic <dpavlin@rot13.org>
16  #  #
# Line 13  Line 18 
18  use Getopt::Std;  use Getopt::Std;
19  use Net::FTP;  use Net::FTP;
20    
21  getopts ("p:t:");  getopts ("p:t:o");
22  $PORT = $opt_p || 21;  $PORT = $opt_p || 21;
23  $TIMEOUT = $opt_t || 30;  $TIMEOUT = $opt_t || 30;
24    
# Line 24  foreach my $host (@ARGV) { Line 29  foreach my $host (@ARGV) {
29          my $result = check_anon_ftp($host);          my $result = check_anon_ftp($host);
30          if ($result) {          if ($result) {
31                  $bad{$host} = $result;                  $bad{$host} = $result;
32            } else {
33                    $good{$host} = "ok";
34          }          }
35  }  }
36    
# Line 37  foreach my $h (keys %bad) { Line 44  foreach my $h (keys %bad) {
44      print "HOST $h: " . $bad{$h}, "\n";      print "HOST $h: " . $bad{$h}, "\n";
45  }  }
46    
47    if ($opt_o && keys %good > 0) {
48            # one host is o.k., don't report warning
49            exit 0;
50    }
51    
52  exit 1;  exit 1;
53    
54  sub check_anon_ftp {  sub check_anon_ftp {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26