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);
|
||||||
|
}
|
|
@ -225,6 +225,13 @@ define command{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 'check_tftp' command definition
|
||||||
|
define command{
|
||||||
|
command_name check_tftp
|
||||||
|
command_line $USER1$/check_tftp -H $HOSTADDRESS$ -f $ARG1$
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# 'check_tcp' command definition
|
# 'check_tcp' command definition
|
||||||
define command{
|
define command{
|
||||||
command_name check_tcp
|
command_name check_tcp
|
||||||
|
|
|
@ -294,6 +294,15 @@ class nagios::server::manual inherits nagios::common {
|
||||||
require => Package["nagios"],
|
require => Package["nagios"],
|
||||||
before => Service["nagios"],
|
before => Service["nagios"],
|
||||||
}
|
}
|
||||||
|
file { "${nagios::common::libdir}/check_tftp":
|
||||||
|
ensure => present,
|
||||||
|
mode => "0755",
|
||||||
|
owner => "root",
|
||||||
|
group => "root",
|
||||||
|
source => "puppet:///modules/nagios/check_tftp",
|
||||||
|
require => Package["nagios"],
|
||||||
|
before => Service["nagios"],
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,23 @@ class nagios::target::submission inherits nagios::target {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure tftp service target.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $file:
|
||||||
|
# Filename to fetch from TFTP server
|
||||||
|
#
|
||||||
|
class nagios::target::tftp($file) inherits nagios::target {
|
||||||
|
|
||||||
|
@@nagios::service { "${::homename}_tftp":
|
||||||
|
command => "check_tftp!${file}",
|
||||||
|
description => "TFTP",
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Configure tcp connect service target.
|
# Configure tcp connect service target.
|
||||||
#
|
#
|
||||||
# === Parameters
|
# === Parameters
|
||||||
|
|
Loading…
Add table
Reference in a new issue