nagios: Added support for tftp service target.
This commit is contained in:
parent
f9ba1455d0
commit
a4282b0400
4 changed files with 64 additions and 0 deletions
31
nagios/files/check_tftp
Executable file
31
nagios/files/check_tftp
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Getopt::Long qw(:config no_ignore_case);
|
||||
|
||||
sub usage() {
|
||||
print "Usage: check_tftp -H <host> -f <file>\n";
|
||||
}
|
||||
|
||||
my ($host, $file);
|
||||
my $result = GetOptions(
|
||||
"H|host=s" => \$host,
|
||||
"f|file=s" => \$file,
|
||||
);
|
||||
|
||||
if (!$host || !$file) {
|
||||
usage();
|
||||
exit(3);
|
||||
}
|
||||
|
||||
$result = `echo -e 'timeout 1\nverbose\nget $file /dev/null' | tftp $host`;
|
||||
my @splitted = split(/\n/, $result);
|
||||
$result = $splitted[5];
|
||||
|
||||
if ($result =~ /Received \d+ bytes in [\d\.]+ seconds/) {
|
||||
print "TFTP OK: $result";
|
||||
exit(0);
|
||||
} else {
|
||||
print "TFTP CRITICAL: $result";
|
||||
exit(2);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue