That worked as expected (timed out, set return code 3) but the nagios emails were unchanged. According to
http://nagios.sourceforge.net/docs/3_0/epnplugins.html, a nagios plug-in should always generate some output so I tried to modify the script further but was unable to master the syntax. Here's the relevant scrippet:
Code:
my $timeout = '60';
my $weekly = 0;
# 11 Apr 2014 Charles for NAG-16:
# * Add timeout, value chosen (above) to be less than service_check_timeout in
# /etc/nagios3/nagios.cf
# * Return nagios service state UNKNOWN on error
# 14 Apr 2014 Charles for NAG-16:
# * Also generate some output
my $sftp = Net::SFTP::Foreign->new($host,timeout=>$timeout,user=>$user);
#$sftp->die_on_error("Unable to establish SFTP connection");
if $sftp->error && {
print "Unable to establish SFTP connection";
exit $ERRORS{'UNKNOWN'};
}
$sftp->setcwd($path) or die "unable to change cwd: " . $sftp->error;
And here's the output:
Code:
root@nagios.bluelight:/usr/lib/nagios/plugins# ./check_amanda.pl redearth /var/lib/amanda/earth-daily backup
Scalar found where operator expected at ./check_amanda.pl line 35, near "$sftp"
(Missing semicolon on previous line?)
syntax error at ./check_amanda.pl line 31, near "if $sftp"
syntax error at ./check_amanda.pl line 34, near "}"
Execution of ./check_amanda.pl aborted due to compilation errors.
I had previously tried
but the reult was similar.