Imported Upstream version 1.4.16+git20130919
This commit is contained in:
parent
01ca3b324f
commit
57371046fd
50 changed files with 3885 additions and 500 deletions
|
@ -44,6 +44,10 @@ for (@responce) {
|
|||
|
||||
my $result;
|
||||
|
||||
# expand paths
|
||||
$ssh_key = glob($ssh_key) if $ssh_key;
|
||||
$ssh_conf = glob($ssh_conf) if $ssh_conf;
|
||||
|
||||
## Single active checks
|
||||
|
||||
for (my $i=0; $i<4; $i++) {
|
||||
|
|
|
@ -6,11 +6,16 @@
|
|||
|
||||
use strict;
|
||||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
plan skip_all => "check_dig not compiled" unless (-x "check_dig");
|
||||
|
||||
plan tests => 16;
|
||||
use vars qw($tests $has_ipv6);
|
||||
BEGIN {
|
||||
plan skip_all => "check_dig not compiled" unless (-x "check_dig");
|
||||
use NPTest;
|
||||
$has_ipv6 = NPTest::has_ipv6();
|
||||
$tests = $has_ipv6 ? 16 : 14;
|
||||
plan tests => $tests;
|
||||
}
|
||||
|
||||
my $successOutput = '/DNS OK - [\.0-9]+ seconds? response time/';
|
||||
|
||||
|
@ -73,10 +78,6 @@ SKIP: {
|
|||
cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
|
||||
like ( $res->output, $successOutput, "Output OK for IPv4" );
|
||||
|
||||
$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -6");
|
||||
cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
|
||||
like ( $res->output, $successOutput, "Output OK for IPv6" );
|
||||
|
||||
$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -a $hostname_valid_ip -t 5");
|
||||
cmp_ok( $res->return_code, '==', 0, "Got expected address");
|
||||
|
||||
|
@ -89,4 +90,9 @@ SKIP: {
|
|||
cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
|
||||
like ( $res->output, $successOutput, "Output OK");
|
||||
|
||||
if($has_ipv6) {
|
||||
$res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -6");
|
||||
cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
|
||||
like ( $res->output, $successOutput, "Output OK for IPv6" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,9 @@ if ($free_on_mp1 > $free_on_mp2) {
|
|||
} else {
|
||||
die "Two mountpoints are the same - cannot do rest of test";
|
||||
}
|
||||
if($free_on_mp1 == $avg_free || $free_on_mp2 == $avg_free) {
|
||||
die "One mountpoints has average space free - cannot do rest of test";
|
||||
}
|
||||
|
||||
|
||||
# Do same for inodes
|
||||
|
@ -74,6 +77,9 @@ if ($free_inode_on_mp1 > $free_inode_on_mp2) {
|
|||
} else {
|
||||
die "Two mountpoints with same inodes free - cannot do rest of test";
|
||||
}
|
||||
if($free_inode_on_mp1 == $avg_inode_free || $free_inode_on_mp2 == $avg_inode_free) {
|
||||
die "One mountpoints has average inodes free - cannot do rest of test";
|
||||
}
|
||||
|
||||
# Verify performance data
|
||||
# First check absolute thresholds...
|
||||
|
|
|
@ -30,12 +30,9 @@ my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
|
|||
"Is this system directly connected to the internet?",
|
||||
"yes");
|
||||
|
||||
my $host_tcp_http2;
|
||||
if ($internet_access eq "no") {
|
||||
$host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
|
||||
my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
|
||||
"A host providing an index page containing the string 'nagios'",
|
||||
"www.nagios.com" );
|
||||
}
|
||||
"nagiosplugins.org" );
|
||||
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
|
@ -65,10 +62,7 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
|
|||
like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
|
||||
|
||||
SKIP: {
|
||||
skip "No internet access and no host serving nagios in index file",
|
||||
7 if $internet_access eq "no" && ! $host_tcp_http2;
|
||||
|
||||
$host_tcp_http2 = "www.nagios.com" if (! $host_tcp_http2);
|
||||
skip "No host serving nagios in index file", 7 unless $host_tcp_http2;
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'");
|
||||
|
|
|
@ -90,7 +90,7 @@ like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet los
|
|||
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_ping $host_nonresponsive -p 1 -t 1 100 100 1000 10000"
|
||||
"./check_ping $host_nonresponsive -p 1 -t 15 100 100 1000 10000"
|
||||
);
|
||||
is( $res->return_code, 2, "Old syntax: Timeout - host nonresponsive" );
|
||||
like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" );
|
||||
|
|
|
@ -34,7 +34,7 @@ $result = NPTest->testCmd( "./check_procs -w 0 -c 0" );
|
|||
is( $result->return_code, 2, "Checking critical if processes > 0" );
|
||||
like( $result->output, '/^PROCS CRITICAL: [0-9]+ process(es)? | procs=[0-9]+;0;0;0;$/', "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( "./check_procs -w 0 -c 0 -s S" );
|
||||
$result = NPTest->testCmd( "./check_procs -w 0 -c 0 -s Ss" );
|
||||
is( $result->return_code, 2, "Checking critical if sleeping processes" );
|
||||
like( $result->output, '/^PROCS CRITICAL: [0-9]+ process(es)? with /', "Output correct" );
|
||||
|
||||
|
|
49
plugins/t/check_ssh.t
Normal file
49
plugins/t/check_ssh.t
Normal file
|
@ -0,0 +1,49 @@
|
|||
#! /usr/bin/perl -w -I ..
|
||||
#
|
||||
# check_ssh tests
|
||||
#
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
# Required parameters
|
||||
my $ssh_host = getTestParameter("NP_SSH_HOST",
|
||||
"A host providing SSH service",
|
||||
"localhost");
|
||||
|
||||
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE",
|
||||
"The hostname of system not responsive to network requests",
|
||||
"10.0.0.1" );
|
||||
|
||||
my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID",
|
||||
"An invalid (not known to DNS) hostname",
|
||||
"nosuchhost" );
|
||||
|
||||
|
||||
plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
|
||||
plan tests => 6;
|
||||
|
||||
|
||||
my $result = NPTest->testCmd(
|
||||
"./check_ssh -H $ssh_host"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)");
|
||||
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_ssh -H $host_nonresponsive -t 2"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)");
|
||||
|
||||
|
||||
|
||||
$result = NPTest->testCmd(
|
||||
"./check_ssh -H $hostname_invalid -t 2"
|
||||
);
|
||||
cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)");
|
||||
like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)");
|
||||
|
|
@ -6,19 +6,13 @@
|
|||
|
||||
use strict;
|
||||
use Test;
|
||||
use NPTest;
|
||||
|
||||
use vars qw($tests);
|
||||
my $has_ipv6;
|
||||
use vars qw($tests $has_ipv6);
|
||||
BEGIN {
|
||||
$tests = 11;
|
||||
# do we have ipv6
|
||||
`ping6 -c 1 2a02:2e0:3fe:100::7 2>&1`;
|
||||
if($? == 0) {
|
||||
$has_ipv6 = 1;
|
||||
$tests += 3;
|
||||
}
|
||||
plan tests => $tests;
|
||||
use NPTest;
|
||||
$has_ipv6 = NPTest::has_ipv6();
|
||||
$tests = $has_ipv6 ? 14 : 11;
|
||||
plan tests => $tests;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ use NPTest;
|
|||
|
||||
my $res;
|
||||
|
||||
alarm(120); # make sure tests don't hang
|
||||
|
||||
plan tests => 14;
|
||||
|
||||
$res = NPTest->testCmd( "./check_udp -H localhost -p 3333" );
|
||||
|
@ -28,9 +30,21 @@ $res = NPTest->testCmd( "./check_udp -H localhost -p 3333 -s foo -e bar" );
|
|||
cmp_ok( $res->return_code, '==', 2, "Errors correctly because no udp service running" );
|
||||
like ( $res->output, '/No data received from host/', "Output OK");
|
||||
|
||||
my $nc;
|
||||
if(system("which nc.traditional >/dev/null 2>&1") == 0) {
|
||||
$nc = 'nc.traditional -w 3 -l -u -p 3333';
|
||||
}
|
||||
elsif(system("which netcat >/dev/null 2>&1") == 0) {
|
||||
$nc = 'netcat -w 3 -l -u -p 3333';
|
||||
}
|
||||
elsif(system("which nc >/dev/null 2>&1") == 0) {
|
||||
$nc = 'nc -w 3 -l -u -4 localhost 3333';
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "No netcat available", 6 unless (system("which nc > /dev/null") == 0);
|
||||
open (NC, "echo 'barbar' | nc -l -p 3333 -u |");
|
||||
skip "solaris netcat does not listen to udp", 6 if $^O eq 'solaris';
|
||||
skip "No netcat available", 6 unless $nc;
|
||||
open (NC, "echo 'barbar' | $nc |");
|
||||
sleep 1;
|
||||
$res = NPTest->testCmd( "./check_udp -H localhost -p 3333 -s '' -e barbar -4" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Got barbar response back" );
|
||||
|
@ -39,7 +53,7 @@ SKIP: {
|
|||
|
||||
# Start up a udp server listening on port 3333, quit after 3 seconds
|
||||
# Otherwise will hang at close
|
||||
my $pid = open(NC, "nc -l -p 3333 -u -w 3 </dev/null |");
|
||||
my $pid = open(NC, "$nc </dev/null |");
|
||||
sleep 1; # Allow nc to startup
|
||||
|
||||
my $start = time;
|
||||
|
@ -53,3 +67,5 @@ SKIP: {
|
|||
cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" );
|
||||
}
|
||||
|
||||
|
||||
alarm(0); # disable alarm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue