New upstream version 2.3.4
This commit is contained in:
parent
e7bdd1c6c6
commit
de72f6f588
556 changed files with 90432 additions and 53391 deletions
|
@ -9,7 +9,7 @@
|
|||
# Country Name (2 letter code) [AU]:DE
|
||||
# State or Province Name (full name) [Some-State]:Bavaria
|
||||
# Locality Name (eg, city) []:Munich
|
||||
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins
|
||||
# Organization Name (eg, company) [Internet Widgets Pty Ltd]:Monitoring Plugins
|
||||
# Organizational Unit Name (eg, section) []:
|
||||
# Common Name (e.g. server FQDN or YOUR name) []:Monitoring Plugins
|
||||
# Email Address []:devel@monitoring-plugins.org
|
||||
|
|
|
@ -9,12 +9,14 @@ use strict;
|
|||
use Test::More;
|
||||
use NPTest;
|
||||
use FindBin qw($Bin);
|
||||
use IO::Socket::INET;
|
||||
|
||||
$ENV{'LC_TIME'} = "C";
|
||||
|
||||
my $common_tests = 71;
|
||||
my $virtual_port_tests = 8;
|
||||
my $ssl_only_tests = 12;
|
||||
my $chunked_encoding_special_tests = 1;
|
||||
# Check that all dependent modules are available
|
||||
eval "use HTTP::Daemon 6.01;";
|
||||
plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
|
||||
|
@ -30,7 +32,7 @@ if ($@) {
|
|||
plan skip_all => "Missing required module for test: $@";
|
||||
} else {
|
||||
if (-x "./$plugin") {
|
||||
plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests;
|
||||
plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests + $chunked_encoding_special_tests;
|
||||
} else {
|
||||
plan skip_all => "No $plugin compiled";
|
||||
}
|
||||
|
@ -51,6 +53,7 @@ my $port_http = 50000 + int(rand(1000));
|
|||
my $port_https = $port_http + 1;
|
||||
my $port_https_expired = $port_http + 2;
|
||||
my $port_https_clientcert = $port_http + 3;
|
||||
my $port_hacked_http = $port_http + 4;
|
||||
|
||||
# This array keeps sockets around for implementing timeouts
|
||||
my @persist;
|
||||
|
@ -72,6 +75,28 @@ if (!$pid) {
|
|||
}
|
||||
push @pids, $pid;
|
||||
|
||||
# Fork the hacked HTTP server
|
||||
undef $pid;
|
||||
$pid = fork;
|
||||
defined $pid or die "Failed to fork";
|
||||
if (!$pid) {
|
||||
# this is the fork
|
||||
undef @pids;
|
||||
my $socket = new IO::Socket::INET (
|
||||
LocalHost => '0.0.0.0',
|
||||
LocalPort => $port_hacked_http,
|
||||
Proto => 'tcp',
|
||||
Listen => 5,
|
||||
Reuse => 1
|
||||
);
|
||||
die "cannot create socket $!n" unless $socket;
|
||||
my $local_sock = $socket->sockport();
|
||||
print "server waiting for client connection on port $local_sock\n";
|
||||
run_hacked_http_server ( $socket );
|
||||
die "hacked http server stopped";
|
||||
}
|
||||
push @pids, $pid;
|
||||
|
||||
if (exists $servers->{https}) {
|
||||
# Fork a normal HTTPS server
|
||||
$pid = fork;
|
||||
|
@ -207,6 +232,37 @@ sub run_server {
|
|||
}
|
||||
}
|
||||
|
||||
sub run_hacked_http_server {
|
||||
my $socket = shift;
|
||||
|
||||
# auto-flush on socket
|
||||
$| = 1;
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
# waiting for a new client connection
|
||||
my $client_socket = $socket->accept();
|
||||
|
||||
# get information about a newly connected client
|
||||
my $client_address = $client_socket->peerhost();
|
||||
my $client_portn = $client_socket->peerport();
|
||||
print "connection from $client_address:$client_portn";
|
||||
|
||||
# read up to 1024 characters from the connected client
|
||||
my $data = "";
|
||||
$client_socket->recv($data, 1024);
|
||||
print "received data: $data";
|
||||
|
||||
# write response data to the connected client
|
||||
$data = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n";
|
||||
$client_socket->send($data);
|
||||
|
||||
# notify client that response has been sent
|
||||
shutdown($client_socket, 1);
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
foreach my $pid (@pids) {
|
||||
if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
|
||||
|
@ -222,6 +278,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
|
|||
my $result;
|
||||
my $command = "./$plugin -H 127.0.0.1";
|
||||
|
||||
run_chunked_encoding_special_test( {command => "$command -p $port_hacked_http"});
|
||||
run_common_tests( { command => "$command -p $port_http" } );
|
||||
SKIP: {
|
||||
skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https};
|
||||
|
@ -511,3 +568,14 @@ sub run_common_tests {
|
|||
};
|
||||
is( $@, "", $cmd );
|
||||
}
|
||||
|
||||
sub run_chunked_encoding_special_test {
|
||||
my ($opts) = @_;
|
||||
my $command = $opts->{command};
|
||||
|
||||
$cmd = "$command -u / -s 'ChunkedEncodingSpecialTest'";
|
||||
eval {
|
||||
$result = NPTest->testCmd( $cmd, 5 );
|
||||
};
|
||||
is( $@, "", $cmd );
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use Test::More;
|
|||
use NPTest;
|
||||
|
||||
if (-x "./check_procs") {
|
||||
plan tests => 52;
|
||||
plan tests => 54;
|
||||
} else {
|
||||
plan skip_all => "No check_procs compiled";
|
||||
}
|
||||
|
@ -34,9 +34,13 @@ is( $result->return_code, 0, "Checking no threshold breeched" );
|
|||
is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( "$command -C launchd -c 5" );
|
||||
is( $result->return_code, 2, "Checking processes filtered by command name" );
|
||||
is( $result->return_code, 2, "Checking processes matched by command name" );
|
||||
is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( "$command -X bash -c 5" );
|
||||
is( $result->return_code, 2, "Checking processes excluded by command name" );
|
||||
is( $result->output, "PROCS CRITICAL: 95 processes with exclude progs 'bash' | procs=95;;5;0;", "Output correct" );
|
||||
|
||||
SKIP: {
|
||||
skip 'user with uid 501 required', 4 unless getpwuid(501);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ if ($pid) {
|
|||
#print "child\n";
|
||||
|
||||
print "Please contact SNMP at: $port_snmp\n";
|
||||
close(STDERR); # Coment out to debug snmpd problems (most errors sent there are OK)
|
||||
close(STDERR); # Comment out to debug snmpd problems (most errors sent there are OK)
|
||||
exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ is($res->output, 'SNMP OK - "555\"I said\"" | ', "Check string with a double quo
|
|||
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.15 -r 'CUSTOM CHECK OK'" );
|
||||
is($res->return_code, 0, "String check should check whole string, not a parsed number" );
|
||||
is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string");
|
||||
is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check with numbers returns whole string");
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
|
||||
is($res->return_code, 0, "Negative integer check OK" );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue