From 44a321cb8a42d6c0ea2d96a1086a17f2134c89cc Mon Sep 17 00:00:00 2001 From: Ethan Galstad Date: Thu, 28 Feb 2002 06:42:51 +0000 Subject: Initial revision git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c --- contrib/check_ftpget.pl | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 contrib/check_ftpget.pl (limited to 'contrib/check_ftpget.pl') 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 @@ +#!/usr/bin/perl -w +## Written 12/5/00 Jeremy Hanmer +# $Id$ + +use strict; +use Net::FTP; +use Getopt::Std; + +use vars qw($opt_H $opt_u $opt_p $opt_f); +getopts("H:u:p:f:"); + +my $host = $opt_H || + die "usage: check_ftp.pl -h host [<-u user> <-p pass> <-f file>]\n"; + +my $username = $opt_u || 'anonymous'; +my $pass = $opt_p || "$ENV{'LOGNAME'}\@$ENV{'HOSTNAME'}" ; + +my $file = $opt_f; + +my $status = 0; +my $problem; +my $output = "ftp ok"; + +my $ftp = Net::FTP->new("$host") || + &crit("connect"); + +$ftp->login("$username", "$pass") || + &crit("login"); + +$ftp->get($file) || + &crit("get") if $file; + +sub crit() +{ + $problem = $_[0]; + $status = 2; + if ( $problem eq 'connect' ) { + $output = "can't connect"; + } elsif ( $problem eq 'login' ) { + $output = "can't log in"; + } elsif ( $problem eq 'get' ) { + $output = "cant get $file"; + } +} + +print "$output\n"; +exit $status; + -- cgit v1.2.3-74-g34f1