Imported Upstream version 1.4.5
This commit is contained in:
parent
62d1e7d5fe
commit
6a280f6f24
412 changed files with 168642 additions and 0 deletions
4
plugins-scripts/t/CVS/Entries
Normal file
4
plugins-scripts/t/CVS/Entries
Normal file
|
@ -0,0 +1,4 @@
|
|||
/check_file_age.t/1.1/Thu Dec 15 15:17:49 2005//Tr1_4_5
|
||||
/check_rpc.t/1.2/Mon Jul 25 01:47:15 2005//Tr1_4_5
|
||||
/utils.t/1.2/Fri Oct 27 15:37:31 2006//Tr1_4_5
|
||||
D
|
1
plugins-scripts/t/CVS/Repository
Normal file
1
plugins-scripts/t/CVS/Repository
Normal file
|
@ -0,0 +1 @@
|
|||
nagiosplug/plugins-scripts/t
|
1
plugins-scripts/t/CVS/Root
Normal file
1
plugins-scripts/t/CVS/Root
Normal file
|
@ -0,0 +1 @@
|
|||
:ext:tonvoon@nagiosplug.cvs.sourceforge.net:/cvsroot/nagiosplug
|
1
plugins-scripts/t/CVS/Tag
Normal file
1
plugins-scripts/t/CVS/Tag
Normal file
|
@ -0,0 +1 @@
|
|||
Nr1_4_5
|
88
plugins-scripts/t/check_file_age.t
Normal file
88
plugins-scripts/t/check_file_age.t
Normal file
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/perl -w -I ..
|
||||
#
|
||||
# check_file_age tests
|
||||
#
|
||||
# $Id: check_file_age.t,v 1.1 2005/12/15 15:17:49 tonvoon Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test::More tests => 15;
|
||||
use NPTest;
|
||||
|
||||
my $successOutput = '/^FILE_AGE OK: /';
|
||||
my $warningOutput = '/^FILE_AGE WARNING: /';
|
||||
my $criticalOutput = '/^FILE_AGE CRITICAL: /';
|
||||
my $unknownOutput = '/^FILE_AGE UNKNOWN: /';
|
||||
|
||||
my $result;
|
||||
my $temp_file = "/tmp/check_file_age.tmp";
|
||||
my $temp_link = "/tmp/check_file_age.link.tmp";
|
||||
|
||||
unlink $temp_file, $temp_link;
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
|
||||
like ( $result->output, $unknownOutput, "Output for unknown correct" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 2, "File not exists" );
|
||||
like ( $result->output, $criticalOutput, "Output for file missing correct" );
|
||||
|
||||
write_chars(100);
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 0, "File is new enough" );
|
||||
like ( $result->output, $successOutput, "Output for success correct" );
|
||||
|
||||
sleep 2;
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file -w 1"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" );
|
||||
like ( $result->output, $warningOutput, "Output for warning correct" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file -c 1"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" );
|
||||
like ( $result->output, $criticalOutput, "Output for critical correct" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file -c 1000 -W 100"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 0, "Checking file size" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file -c 1000 -W 101"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 1, "One byte too short" );
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_file_age -f $temp_file -c 1000 -C 101"
|
||||
);
|
||||
cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" );
|
||||
|
||||
symlink $temp_file, $temp_link or die "Cannot create symlink";
|
||||
$result = NPTest->testCmd("./check_file_age -f $temp_link -c 10");
|
||||
cmp_ok( $result->return_code, '==', 0, "Works for symlinks" );
|
||||
unlink $temp_link;
|
||||
|
||||
unlink $temp_file;
|
||||
mkdir $temp_file or die "Cannot create directory";
|
||||
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1");
|
||||
cmp_ok( $result->return_code, '==', 0, "Works for directories" );
|
||||
rmdir $temp_file;
|
||||
|
||||
|
||||
sub write_chars {
|
||||
my $size = shift;
|
||||
open F, "> $temp_file" or die "Cannot write to $temp_file";
|
||||
print F "A" x $size;
|
||||
close F;
|
||||
}
|
22
plugins-scripts/t/check_rpc.t
Normal file
22
plugins-scripts/t/check_rpc.t
Normal file
|
@ -0,0 +1,22 @@
|
|||
#! /usr/bin/perl -w -I ..
|
||||
#
|
||||
# Remote Procedure Call (RPC) Tests via check_rpc
|
||||
#
|
||||
# $Id: check_rpc.t,v 1.2 2005/07/25 01:47:15 illumino Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test;
|
||||
use NPTest;
|
||||
|
||||
use vars qw($tests);
|
||||
BEGIN {$tests = 2; plan tests => $tests}
|
||||
|
||||
my $successOutput = '/^check_rpc/';
|
||||
|
||||
my $t;
|
||||
|
||||
$t += checkCmd( "./check_rpc -V", 0, $successOutput );
|
||||
|
||||
exit(0) if defined($Test::Harness::VERSION);
|
||||
exit($tests - $t);
|
49
plugins-scripts/t/utils.t
Normal file
49
plugins-scripts/t/utils.t
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/perl -w -I ..
|
||||
#
|
||||
# utils.pm tests
|
||||
#
|
||||
# $Id: utils.t,v 1.2 2006/10/27 15:37:31 tonvoon Exp $
|
||||
#
|
||||
# Run with perl t/utils.t
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
use lib "..";
|
||||
use utils;
|
||||
|
||||
my $hostname_checks = {
|
||||
"www.altinity.com" => 1,
|
||||
"www.888.com" => 1,
|
||||
"888.com" => 1,
|
||||
"host-hyphened.com" => 1,
|
||||
"rubbish" => 1,
|
||||
"-start.com" => 0,
|
||||
"nonfqdn-but-endsindot." => 1,
|
||||
"fqdn.and.endsindot." => 1,
|
||||
"lots.of.dots.dot.org" => 1,
|
||||
"endingwithdoubledots.." => 0,
|
||||
"toomany..dots" => 0,
|
||||
".start.with.dot" => 0,
|
||||
"10.20.30.40" => 1,
|
||||
"10.20.30.40.50" => 0,
|
||||
"10.20.30" => 0,
|
||||
"10.20.30.40." => 1, # This is considered a hostname because of trailing dot. It probably won't exist though...
|
||||
"888." => 1, # This is because it could be a domain
|
||||
"host.888." => 1,
|
||||
"where.did.that.!.come.from." => 0,
|
||||
"no.underscores_.com" => 0,
|
||||
};
|
||||
|
||||
plan tests => ((scalar keys %$hostname_checks) + 4);
|
||||
|
||||
foreach my $h (sort keys %$hostname_checks) {
|
||||
is (utils::is_hostname($h), $hostname_checks->{$h}, "$h should return ".$hostname_checks->{$h});
|
||||
}
|
||||
|
||||
is(utils::is_hostname(), 0, "No parameter errors");
|
||||
is(utils::is_hostname(""), 0, "Empty string errors");
|
||||
is(utils::is_hostname(0), 0, "0 also errors");
|
||||
is(utils::is_hostname(1), 0, "1 also errors");
|
Loading…
Add table
Add a link
Reference in a new issue