check_tftp error


Hello all,

I use GroundWork Community Edition v5.3.0
With Nagios® 3.0.6.

I want to test my TFTP servers (services) by using the following check command;

require 5.004;
use strict;
use POSIX;
use Getopt::Long qw(:config no_ignore_case);

use lib ‘/usr/local/libexec/nagios’;
use utils qw($TIMEOUT %ERRORS &print_revision &support);

use vars qw($ME $VERSION %Flags $Help $Usage $Verbose $Host $Port $Tftp_Cmd);

$VERSION = ‘0.’. (split(’ ', ‘$Id: check_tftp,v 1.2 2005/02/13 02:06:35 root Exp $’))[2];
$ME = ‘check_tftp’;

tftp command to get connection state

$Tftp_Cmd = ‘echo status | /usr/bin/tftp %s %s’;

$Usage = “$ME: -H host -p port] -v]”;
$Help = <<EOhelp;
$ME: Nagios plugin to check a tftp server

$ME ] -H host -p port] -v]
$ME --help
$ME --man
$ME --version

–hostname The name of the host running the tftp server.
–port The port on which the tftp service should be running.
–verbose|-v Show details of progress (give more than once for more info).
–help Show this usage text.
–man Show the comprehensive documentation.
–version Show the version ($VERSION).


handle the command-line

$Verbose = 0;
GetOptions(‘verbose|v+’ => $Verbose,
‘version|V’ => $Flags{version},
‘help|h’ => $Flags{help},
‘man|m’ => $Flags{man},
‘hostname|H=s’ => $Host,
‘port|p=s’ => $Port,
or die($Usage);
if ($Flags{version}) {
print_revision($ME, $VERSION);
exit 0;
elsif ($Flags{help}) {
print $Help;
exit 0;
elsif ($Flags{man}) {
use Pod::Usage;
pod2usage(-verbose => 2, -exitval => 0);

if (!$Host) {
print “ERROR: Sorry, but a hostname must be given.\n\n”.
elsif (! utils::is_hostname($Host)) {
print “ERROR: Sorry, but “$Host” doesn’t look like a host name.\n”;

my $cmd = sprintf $Tftp_Cmd, $Host, $Port;
print “opening $cmd\n” if $Verbose;
my @out = $cmd;
print “output is:\n\n@out\n” if $Verbose;
my $status = $out[0];

my ($state, $answer);
if ($status =~ /^Connected to/) {
$state = $ERRORS{OK};
$answer = $status;
chomp $answer;
else {
$answer = $status;
chomp $answer;

foreach my $errname (keys %ERRORS) {
if ($state == $ERRORS{$errname}) {
print “TFTP $errname: $answer\n”;
exit $state;

But when ever i try to test it i get these results;

/usr/local/groundwork/nagios/libexec/check_tftp -H {MyTFTPServer} -p 69

TFTP CRITICAL: tftp> Connected to {MyTFTPServer}.

Command returned exit status 2

I hope you guys can help me out, cause i have tried everything but i cannot correct this problem.

Kind Regards,