#!/usr/local/bin/perl use Net::FTP; use Nagios::Plugin; my $ng = Nagios::Plugin->new( usage => "Usage: %s -H -u -p ", ); $ng->add_arg( spec => 'host|H=s', help => "FTP Host", required => 1, ); $ng->add_arg( spec => 'user|u=s', help => "FTP User", required => 1, ); $ng->add_arg( spec => 'password|p=s', help => "FTP Password", required => 1, ); $ng->getopts; my $ftp; unless ($ftp = Net::FTP->new($ng->opts->host)) { my $message="Could not connect to host"; $ng->nagios_exit( CRITICAL, $message ) } unless ($ftp->login($ng->opts->user,$ng->opts->password)) { my $message="Login failed with user '".$ng->opts->user."'"; $ng->nagios_exit( CRITICAL, $message ) } $ftp->quit; $ng->nagios_exit( OK, $message );