diff options
| author | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 +0000 |
|---|---|---|
| committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 +0000 |
| commit | 44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch) | |
| tree | a1a4d9f7b92412a17ab08f34f04eec45433048b7 /contrib/check_ftpget.pl | |
| parent | 54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff) | |
| download | monitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz | |
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_ftpget.pl')
| -rwxr-xr-x | contrib/check_ftpget.pl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/contrib/check_ftpget.pl b/contrib/check_ftpget.pl new file mode 100755 index 00000000..de7e8242 --- /dev/null +++ b/contrib/check_ftpget.pl | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | #!/usr/bin/perl -w | ||
| 2 | ## Written 12/5/00 Jeremy Hanmer | ||
| 3 | # $Id$ | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use Net::FTP; | ||
| 7 | use Getopt::Std; | ||
| 8 | |||
| 9 | use vars qw($opt_H $opt_u $opt_p $opt_f); | ||
| 10 | getopts("H:u:p:f:"); | ||
| 11 | |||
| 12 | my $host = $opt_H || | ||
| 13 | die "usage: check_ftp.pl -h host [<-u user> <-p pass> <-f file>]\n"; | ||
| 14 | |||
| 15 | my $username = $opt_u || 'anonymous'; | ||
| 16 | my $pass = $opt_p || "$ENV{'LOGNAME'}\@$ENV{'HOSTNAME'}" ; | ||
| 17 | |||
| 18 | my $file = $opt_f; | ||
| 19 | |||
| 20 | my $status = 0; | ||
| 21 | my $problem; | ||
| 22 | my $output = "ftp ok"; | ||
| 23 | |||
| 24 | my $ftp = Net::FTP->new("$host") || | ||
| 25 | &crit("connect"); | ||
| 26 | |||
| 27 | $ftp->login("$username", "$pass") || | ||
| 28 | &crit("login"); | ||
| 29 | |||
| 30 | $ftp->get($file) || | ||
| 31 | &crit("get") if $file; | ||
| 32 | |||
| 33 | sub crit() | ||
| 34 | { | ||
| 35 | $problem = $_[0]; | ||
| 36 | $status = 2; | ||
| 37 | if ( $problem eq 'connect' ) { | ||
| 38 | $output = "can't connect"; | ||
| 39 | } elsif ( $problem eq 'login' ) { | ||
| 40 | $output = "can't log in"; | ||
| 41 | } elsif ( $problem eq 'get' ) { | ||
| 42 | $output = "cant get $file"; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | print "$output\n"; | ||
| 47 | exit $status; | ||
| 48 | |||
