/[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

Annotation of /anon_ftp.monitor

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Mon Sep 2 11:57:03 2002 UTC (18 years, 10 months ago) by dpavlin
Branch: MAIN
monitor anonymous ftp server using Net::FTP

1 dpavlin 1.1 #!/usr/bin/perl
2     #
3     # Use try to connect to a FTP server using Net::FTP, login as
4     # anonymous and issue PWD.
5     #
6     # For use with "mon".
7     #
8     # Arguments are "-p port -t timeout host [host...]"
9     #
10     # 2002-09-02 Dobrica Pavlinusic <dpavlin@rot13.org>
11     #
12    
13     use Getopt::Std;
14     use Net::FTP;
15    
16     getopts ("p:t:");
17     $PORT = $opt_p || 21;
18     $TIMEOUT = $opt_t || 30;
19    
20     my %bad;
21    
22     foreach my $host (@ARGV) {
23    
24     my $result = check_anon_ftp($host);
25     if ($result) {
26     $bad{$host} = $result;
27     }
28     }
29    
30     if (keys %bad == 0) {
31     exit 0;
32     }
33    
34     print join (" ", sort keys %bad), "\n";
35    
36     foreach my $h (keys %bad) {
37     print "HOST $h: " . $bad{$h}, "\n";
38     }
39    
40     exit 1;
41    
42     sub check_anon_ftp {
43     my ($host) = @_;
44     $ftp = Net::FTP->new($host, Debug => 0, Timeout => $TIMEOUT, Port => $PORT) || return "can't connect to $host:$PORT for $TIMEOUT seconds.";
45     $ftp->login("anonymous",'mon@kernel.org') || return "$host: can't login as anonymous";
46     my $dir = $ftp->pwd || return "$host: can't do PWD";
47     $ftp->quit;
48     return 0;
49     }
50    

  ViewVC Help
Powered by ViewVC 1.1.26