Code: Select all
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/ftp.pl, ...) failed. errno is 2: No such file or directory
I've posted copies of my command, host, and template files below, along with the script itself. What in the world could be causing this?
Host definition:
Code: Select all
define host{
use transfer-template
host_name FTP Health Check
alias FTP Health Check
check_command check_ftp
}
Code: Select all
define host{
name transfer-template ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 1 ; Actively check the server every 1 minutes
retry_interval 0.5 ; Schedule host check retries at 0.5 minute intervals
max_check_attempts 2 ; Check each server 2 times (max)
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 10 ; Resend notifications every 10 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups 2 ; Host groups that Windows servers should be a member of
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}
Code: Select all
define command{
command_name check_ftp
command_line $USER1$/ftp.pl
}
Code: Select all
#!usr/bin/perl
use Net::FTP;
use lib "PATH TO LIBRARY";
#use Try::Tiny; /depreciated
use Time::Piece;
$host = "FTP SERVER";
$user = "FTP USERNAME";
$pw = "FTP PASSWORD";
$dir = "Test";
$getFile = "ftptest";
$putFile = "/usr/local/nagios/Misc/ftptest";
$date = localtime->strftime('%m/%d/%Y %H:%M');
#Writes current date to file for nagios checking
open (FILE, ">$putFile\n");
print FILE "$date\n";
close (FILE);
#Connects to FTP directory
$ftp = Net::FTP->new($host) or die "Can't open $host\n";
$ftp->login($user, $pw) or die "Can't login with $user\n";
$ftp->cwd($dir) or die "Can't connect to $dir\n";
#Sends to directory, gets from directory
$ftp->put($putFile);
$ftp->get($getFile);
#Reads date from file to make sure it matches $date
open(FILE, "$getFile");
while(<FILE>){
chomp;
$fileOut = $_;
}
#Nagios logic
if ($fileOut == $date) {
print "OK - FTP Services Working\n";
exit 0; #Nagios OK return code
}
else {
print "CRITICAL - FTP services degraded\n";
exit 2; #Nagios CRITICAL return code
}