New upstream version 2.3
This commit is contained in:
parent
0f5a7fe8f1
commit
3031044324
129 changed files with 14313 additions and 2999 deletions
|
@ -1,58 +1,54 @@
|
|||
{
|
||||
'MYSQL_LOGIN_DETAILS' => '-u root -d test',
|
||||
'NP_ALLOW_SUDO' => 'yes',
|
||||
'NP_DNS_SERVER' => '8.8.8.8',
|
||||
'NP_GOOD_NTP_SERVICE' => '',
|
||||
'NP_HOSTNAME_INVALID' => 'nosuchhost',
|
||||
'NP_HOSTNAME_VALID' => 'monitoringplugins.org',
|
||||
'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
|
||||
'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
|
||||
'NP_HOST_DHCP_RESPONSIVE' => '',
|
||||
'NP_HOST_HPJD_PORT_INVALID' => '161',
|
||||
'NP_HOST_HPJD_PORT_VALID' => '',
|
||||
'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30',
|
||||
'NP_HOSTNAME_INVALID' => 'nosuchhost',
|
||||
'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30',
|
||||
'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
|
||||
'NP_HOSTNAME_VALID' => 'monitoring-plugins.org',
|
||||
'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
|
||||
'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
|
||||
'NP_HOST_RESPONSIVE' => 'localhost',
|
||||
'NP_HOST_SMB' => '',
|
||||
'NP_HOST_SNMP' => 'localhost',
|
||||
'NP_HOST_SNMP' => '',
|
||||
'NP_HOST_TCP_FTP' => '',
|
||||
'NP_HOST_TCP_HPJD' => '',
|
||||
'NP_HOST_HPJD_PORT_INVALID' => '161',
|
||||
'NP_HOST_HPJD_PORT_VALID' => '',
|
||||
'NP_HOST_TCP_HTTP' => 'localhost',
|
||||
'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org',
|
||||
'NP_HOST_TCP_HTTP' => 'localhost',
|
||||
'NP_HOST_TCP_IMAP' => 'imap.web.de',
|
||||
'NP_HOST_TCP_JABBER' => 'jabber.org',
|
||||
'NP_HOST_TCP_LDAP' => 'localhost',
|
||||
'NP_HOST_TCP_POP' => 'pop.web.de',
|
||||
'NP_HOST_TCP_PROXY' => 'localhost',
|
||||
'NP_HOST_TCP_SMTP' => 'localhost',
|
||||
'NP_HOST_TCP_SMTP_NOTLS' => '',
|
||||
'NP_HOST_TCP_SMTP_TLS' => '',
|
||||
'NP_HOST_TLS_CERT' => 'localhost,
|
||||
'NP_HOST_TLS_HTTP' => 'localhost',
|
||||
'NP_HOST_UDP_TIME' => 'none',
|
||||
'NP_INTERNET_ACCESS' => 'yes',
|
||||
'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain',
|
||||
'NP_MOUNTPOINT2_VALID' => '/media/ramdisk',
|
||||
'NP_MOUNTPOINT_VALID' => '/',
|
||||
'NP_MYSQL_LOGIN_DETAILS' => '-u root -d test',
|
||||
'NP_MYSQL_SERVER' => 'localhost',
|
||||
'NP_HOST_UDP_TIME' => 'localhost',
|
||||
'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock',
|
||||
'NP_MYSQL_WITH_SLAVE' => '',
|
||||
'NP_MYSQL_WITH_SLAVE_LOGIN' => '',
|
||||
'NP_NO_NTP_SERVICE' => 'localhost',
|
||||
'NP_PORT_TCP_PROXY' => '3128',
|
||||
'NP_SMB_SHARE' => '',
|
||||
'NP_SMB_SHARE_DENY' => '',
|
||||
'NP_SMB_SHARE_SPC' => '',
|
||||
'NP_SMB_VALID_USER' => '',
|
||||
'NP_SMB_VALID_USER_PASS' => '',
|
||||
'NP_SNMP_COMMUNITY' => 'public',
|
||||
'NP_SNMP_COMMUNITY' => '',
|
||||
'NP_SNMP_USER' => '',
|
||||
'NP_SSH_CONFIGFILE' => '~/.ssh/config',
|
||||
'NP_SSH_HOST' => 'localhost',
|
||||
'NP_SSH_IDENTITY' => '~/.ssh/id_dsa',
|
||||
'NP_HOST_TCP_JABBER' => 'jabber.org',
|
||||
'host_nonresponsive' => '10.0.0.1',
|
||||
'host_responsive' => 'localhost',
|
||||
'host_snmp' => '',
|
||||
'host_tcp_ftp' => '',
|
||||
'host_tcp_http' => 'localhost',
|
||||
'host_tcp_imap' => 'imap.nierlein.de',
|
||||
'host_tcp_smtp' => 'localhost',
|
||||
'hostname_invalid' => 'nosuchhost',
|
||||
'snmp_community' => '',
|
||||
'user_snmp' => '',
|
||||
'host_udp_time' => 'none',
|
||||
'NP_SSH_IDENTITY' => '~/.ssh/id_rsa'
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ sub make_result_regexp {
|
|||
}
|
||||
|
||||
if (-x "./check_apt") {
|
||||
plan tests => 28;
|
||||
plan tests => 36;
|
||||
} else {
|
||||
plan skip_all => "No check_apt compiled";
|
||||
}
|
||||
|
@ -40,10 +40,18 @@ $result = NPTest->testCmd( sprintf($testfile_command, "", "debian2") );
|
|||
is( $result->return_code, 1, "Debian apt output, warning" );
|
||||
like( $result->output, make_result_regexp(13, 0), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian2") );
|
||||
is( $result->return_code, 0, "Debian apt output, no critical" );
|
||||
like( $result->output, make_result_regexp(13, 0), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") );
|
||||
is( $result->return_code, 2, "Debian apt output, some critical" );
|
||||
like( $result->output, make_result_regexp(19, 4), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian3") );
|
||||
is( $result->return_code, 2, "Debian apt output, some critical" );
|
||||
like( $result->output, make_result_regexp(19, 4), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") );
|
||||
is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" );
|
||||
like( $result->output, make_result_regexp(19, 4), "Output correct" );
|
||||
|
@ -52,6 +60,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") );
|
|||
is( $result->return_code, 1, "Debian apt output, filter for libc6" );
|
||||
like( $result->output, make_result_regexp(3, 0), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") );
|
||||
is( $result->return_code, 1, "Debian apt output, filter for libc6, not critical" );
|
||||
like( $result->output, make_result_regexp(3, 0), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") );
|
||||
is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" );
|
||||
like( $result->output, make_result_regexp(9, 4), "Output correct" );
|
||||
|
@ -64,6 +76,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6", "debian3") );
|
|||
is( $result->return_code, 2, "Debian apt output, filter out libc6" );
|
||||
like( $result->output, make_result_regexp(16, 4), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -o", "debian3") );
|
||||
is( $result->return_code, 2, "Debian apt output, filter out libc6, critical" );
|
||||
like( $result->output, make_result_regexp(16, 4), "Output correct" );
|
||||
|
||||
$result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") );
|
||||
is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" );
|
||||
like( $result->output, make_result_regexp(10, 0), "Output correct" );
|
||||
|
|
|
@ -9,17 +9,9 @@ use Test::More;
|
|||
use NPTest;
|
||||
|
||||
# Required parameters
|
||||
my $ssh_service = getTestParameter( "NP_SSH_HOST",
|
||||
"A host providing SSH service",
|
||||
"localhost");
|
||||
|
||||
my $ssh_key = getTestParameter( "NP_SSH_IDENTITY",
|
||||
"A key allowing access to NP_SSH_HOST",
|
||||
"~/.ssh/id_dsa");
|
||||
|
||||
my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE",
|
||||
"A config file with ssh settings",
|
||||
"~/.ssh/config");
|
||||
my $ssh_service = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost");
|
||||
my $ssh_key = getTestParameter("NP_SSH_IDENTITY", "A key allowing access to NP_SSH_HOST", "~/.ssh/id_dsa");
|
||||
my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", "A config file with ssh settings", "~/.ssh/config");
|
||||
|
||||
|
||||
plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key);
|
||||
|
|
199
plugins/t/check_curl.t
Normal file
199
plugins/t/check_curl.t
Normal file
|
@ -0,0 +1,199 @@
|
|||
#! /usr/bin/perl -w -I ..
|
||||
#
|
||||
# HyperText Transfer Protocol (HTTP) Test via check_http
|
||||
#
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Test::More;
|
||||
use POSIX qw/mktime strftime/;
|
||||
use NPTest;
|
||||
|
||||
plan tests => 57;
|
||||
|
||||
my $successOutput = '/OK.*HTTP.*second/';
|
||||
|
||||
my $res;
|
||||
my $plugin = 'check_http';
|
||||
$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
|
||||
|
||||
my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
|
||||
my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
|
||||
my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "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");
|
||||
my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes");
|
||||
my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org");
|
||||
my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost");
|
||||
my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128");
|
||||
|
||||
my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
|
||||
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./$plugin $host_tcp_http -wt 300 -ct 600"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
|
||||
like( $res->output, $successOutput, "Output OK" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
|
||||
);
|
||||
like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
|
||||
# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
|
||||
cmp_ok( $res->output, 'eq', "HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Timeout was reached", "Output OK");
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./$plugin $hostname_invalid -wt 1 -ct 2"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
|
||||
# The first part of the message comes from the OS catalogue, so cannot check this.
|
||||
# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename
|
||||
# Is also possible to get a socket timeout if DNS is not responding fast enough
|
||||
# cURL gives us consistent strings from it's own 'lib/strerror.c'
|
||||
like( $res->output, "/cURL returned 6 - Couldn't resolve host name/", "Output OK");
|
||||
|
||||
# host header checks
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
|
||||
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http -p 80");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
|
||||
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
|
||||
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
|
||||
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80 -k 'Host: testhost:8001'");
|
||||
like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" );
|
||||
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -I $host_tcp_http -p 80 -k 'Host: testhost:8001'");
|
||||
like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" );
|
||||
like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
|
||||
|
||||
SKIP: {
|
||||
skip "No internet access", 3 if $internet_access eq "no";
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S");
|
||||
like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http:8080 -S -p 443");
|
||||
like( $res->output, '/^Host: '.$host_tls_http.':8080\s*$/ms', "Host Header OK" );
|
||||
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443");
|
||||
like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
|
||||
};
|
||||
|
||||
SKIP: {
|
||||
skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'");
|
||||
like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
|
||||
like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 0, "And also when not found");
|
||||
}
|
||||
SKIP: {
|
||||
skip "No internet access", 16 if $internet_access eq "no";
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./$plugin --ssl $host_tls_http"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 0, "Can read https for $host_tls_http" );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -C 1 --ssl $host_tls_http" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Checking certificate for $host_tls_http");
|
||||
like ( $res->output, "/Certificate '$host_tls_cert' will expire on/", "Output OK" );
|
||||
my $saved_cert_output = $res->output;
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" );
|
||||
cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http");
|
||||
like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
|
||||
is( $res->return_code, 0, "Old syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" );
|
||||
is( $res->return_code, 0, "Updated syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
|
||||
|
||||
# run some certificate checks with faketime
|
||||
SKIP: {
|
||||
skip "No faketime binary found", 12 if !$faketime;
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output");
|
||||
is( $res->return_code, 0, "Catch cert output exit code" );
|
||||
my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
|
||||
if(!defined $year) {
|
||||
die("parsing date failed from: ".$res->output);
|
||||
}
|
||||
my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
|
||||
my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
|
||||
my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts));
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date");
|
||||
is( $res->return_code, 2, "Output on expire date" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output");
|
||||
is( $res->return_code, 2, "cert expires in 1 second exit code" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output");
|
||||
is( $res->return_code, 2, "cert expires in 2 minutes exit code" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output");
|
||||
is( $res->return_code, 2, "cert expires in 2 hours exit code" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output");
|
||||
is( $res->return_code, 2, "Certificate expired exit code" );
|
||||
};
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -E" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./$plugin --ssl -H www.e-paycobalt.com"
|
||||
);
|
||||
cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
|
||||
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
|
||||
is( $res->return_code, 0, "Redirection based on location is okay");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
}
|
|
@ -248,11 +248,11 @@ $result = NPTest->testCmd( "./check_disk -w 100% -c 100% ".${mountpoint_valid} )
|
|||
cmp_ok( $result->return_code, "==", 2, "100% empty" );
|
||||
like( $result->output, $failureOutput, "Right output" );
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 100000 -c 100000 $mountpoint_valid" );
|
||||
cmp_ok( $result->return_code, '==', 2, "Check for 100GB free" );
|
||||
$result = NPTest->testCmd( "./check_disk -w 100000000 -c 100000000 $mountpoint_valid" );
|
||||
cmp_ok( $result->return_code, '==', 2, "Check for 100TB free" );
|
||||
|
||||
$result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u GB ".${mountpoint_valid} ); # 100 GB empty
|
||||
cmp_ok( $result->return_code, "==", 2, "100 GB empty" );
|
||||
$result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u TB ".${mountpoint_valid} ); # 100 TB empty
|
||||
cmp_ok( $result->return_code, "==", 2, "100 TB empty" );
|
||||
|
||||
|
||||
# Checking old syntax of check_disk warn crit [fs], with warn/crit at USED% thresholds
|
||||
|
|
|
@ -10,26 +10,38 @@ use NPTest;
|
|||
|
||||
plan skip_all => "check_dns not compiled" unless (-x "check_dns");
|
||||
|
||||
plan tests => 16;
|
||||
plan tests => 19;
|
||||
|
||||
my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
|
||||
|
||||
my $hostname_valid = getTestParameter(
|
||||
"NP_HOSTNAME_VALID",
|
||||
"A valid (known to DNS) hostname",
|
||||
"monitoring-plugins.org"
|
||||
"monitoring-plugins.org",
|
||||
);
|
||||
|
||||
my $hostname_valid_ip = getTestParameter(
|
||||
"NP_HOSTNAME_VALID_IP",
|
||||
"The IP address of the valid hostname $hostname_valid",
|
||||
"66.118.156.50",
|
||||
"130.133.8.40",
|
||||
);
|
||||
|
||||
my $hostname_valid_cidr = getTestParameter(
|
||||
"NP_HOSTNAME_VALID_CIDR",
|
||||
"An valid CIDR range containing $hostname_valid_ip",
|
||||
"130.133.8.41/30",
|
||||
);
|
||||
|
||||
my $hostname_invalid_cidr = getTestParameter(
|
||||
"NP_HOSTNAME_INVALID_CIDR",
|
||||
"An (valid) CIDR range NOT containing $hostname_valid_ip",
|
||||
"130.133.8.39/30",
|
||||
);
|
||||
|
||||
my $hostname_valid_reverse = getTestParameter(
|
||||
"NP_HOSTNAME_VALID_REVERSE",
|
||||
"The hostname of $hostname_valid_ip",
|
||||
"66-118-156-50.static.sagonet.net.",
|
||||
"orwell.monitoring-plugins.org.",
|
||||
);
|
||||
|
||||
my $hostname_invalid = getTestParameter(
|
||||
|
@ -87,3 +99,9 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev
|
|||
cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
|
||||
like ( $res->output, $successOutput, "Output OK");
|
||||
|
||||
$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_cidr -t 5");
|
||||
cmp_ok( $res->return_code, '==', 0, "Got expected address");
|
||||
|
||||
$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5");
|
||||
cmp_ok( $res->return_code, '==', 2, "Got wrong address");
|
||||
like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK");
|
||||
|
|
|
@ -15,15 +15,9 @@ BEGIN {$tests = 4; plan tests => $tests}
|
|||
my $successOutput = '/^FPING OK - /';
|
||||
my $failureOutput = '/^FPING CRITICAL - /';
|
||||
|
||||
my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost",
|
||||
"The hostname of system responsive to network requests" );
|
||||
|
||||
my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
|
||||
my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "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");
|
||||
|
||||
my $t;
|
||||
|
||||
|
|
|
@ -11,14 +11,9 @@ use NPTest;
|
|||
use vars qw($tests);
|
||||
BEGIN {$tests = 4; plan tests => $tests}
|
||||
|
||||
my $host_tcp_ftp = getTestParameter( "host_tcp_ftp", "NP_HOST_TCP_FTP", "localhost",
|
||||
"A host providing the FTP Service (an FTP server)");
|
||||
|
||||
my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
my $host_tcp_ftp = getTestParameter("NP_HOST_TCP_FTP", "A host providing the FTP Service (an FTP server)", "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");
|
||||
|
||||
my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/';
|
||||
|
||||
|
|
|
@ -9,54 +9,46 @@ use Test::More;
|
|||
use POSIX qw/mktime strftime/;
|
||||
use NPTest;
|
||||
|
||||
plan tests => 49;
|
||||
plan tests => 50;
|
||||
|
||||
my $successOutput = '/OK.*HTTP.*second/';
|
||||
|
||||
my $res;
|
||||
my $plugin = 'check_http';
|
||||
$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
|
||||
|
||||
my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP",
|
||||
"A host providing the HTTP Service (a web server)",
|
||||
"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");
|
||||
|
||||
my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
|
||||
"Is this system directly connected to the internet?",
|
||||
"yes");
|
||||
|
||||
my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
|
||||
"A host providing an index page containing the string 'monitoring'",
|
||||
"test.monitoring-plugins.org" );
|
||||
my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
|
||||
my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
|
||||
my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "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");
|
||||
my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes");
|
||||
my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org");
|
||||
my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost");
|
||||
my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128");
|
||||
|
||||
my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
|
||||
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http $host_tcp_http -wt 300 -ct 600"
|
||||
"./$plugin $host_tcp_http -wt 300 -ct 600"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
|
||||
like( $res->output, $successOutput, "Output OK" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
|
||||
"./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
|
||||
);
|
||||
like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http $host_nonresponsive -wt 1 -ct 2 -t 3"
|
||||
"./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
|
||||
cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK");
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http $hostname_invalid -wt 1 -ct 2"
|
||||
"./$plugin $hostname_invalid -wt 1 -ct 2"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
|
||||
# The first part of the message comes from the OS catalogue, so cannot check this.
|
||||
|
@ -65,87 +57,87 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
|
|||
like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
|
||||
|
||||
# host header checks
|
||||
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http");
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
|
||||
|
||||
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http -p 80");
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http -p 80");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
|
||||
|
||||
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
|
||||
|
||||
$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
|
||||
like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
|
||||
|
||||
SKIP: {
|
||||
skip "No internet access", 3 if $internet_access eq "no";
|
||||
|
||||
$res = NPTest->testCmd("./check_http -v -H www.verisign.com -S");
|
||||
like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S");
|
||||
like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
|
||||
|
||||
$res = NPTest->testCmd("./check_http -v -H www.verisign.com:8080 -S -p 443");
|
||||
like( $res->output, '/^Host: www.verisign.com:8080\s*$/ms', "Host Header OK" );
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http:8080 -S -p 443");
|
||||
like( $res->output, '/^Host: '.$host_tls_http.':8080\s*$/ms', "Host Header OK" );
|
||||
|
||||
$res = NPTest->testCmd("./check_http -v -H www.verisign.com:443 -S -p 443");
|
||||
like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
|
||||
$res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443");
|
||||
like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
|
||||
};
|
||||
|
||||
SKIP: {
|
||||
skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring'" );
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing'" );
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'");
|
||||
like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'mONiTORing'" );
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
|
||||
like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 0, "And also when not found");
|
||||
}
|
||||
SKIP: {
|
||||
skip "No internet access", 16 if $internet_access eq "no";
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http --ssl www.verisign.com"
|
||||
"./$plugin --ssl $host_tls_http"
|
||||
);
|
||||
cmp_ok( $res->return_code, '==', 0, "Can read https for www.verisign.com" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Can read https for $host_tls_http" );
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -C 1 --ssl www.verisign.com" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Checking certificate for www.verisign.com");
|
||||
like ( $res->output, "/Certificate 'www.verisign.com' will expire on/", "Output OK" );
|
||||
$res = NPTest->testCmd( "./$plugin -C 1 --ssl $host_tls_http" );
|
||||
cmp_ok( $res->return_code, '==', 0, "Checking certificate for $host_tls_http");
|
||||
like ( $res->output, "/Certificate '$host_tls_cert' will expire on/", "Output OK" );
|
||||
my $saved_cert_output = $res->output;
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -C 8000,1 --ssl www.verisign.com" );
|
||||
cmp_ok( $res->return_code, '==', 1, "Checking certificate for www.verisign.com");
|
||||
like ( $res->output, qr/WARNING - Certificate 'www.verisign.com' expires in \d+ day/, "Output Warning" );
|
||||
$res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" );
|
||||
cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http");
|
||||
like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" );
|
||||
|
||||
$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
|
||||
$res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
|
||||
is( $res->return_code, 0, "Old syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H www.verisign.com -C 1" );
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" );
|
||||
is( $res->return_code, 0, "Updated syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -C 1 www.verisign.com" );
|
||||
$res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
|
||||
$res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
|
||||
|
||||
# run some certificate checks with faketime
|
||||
SKIP: {
|
||||
skip "No faketime binary found", 12 if !$faketime;
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com");
|
||||
like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output");
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output");
|
||||
is( $res->return_code, 0, "Catch cert output exit code" );
|
||||
my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
|
||||
if(!defined $year) {
|
||||
|
@ -154,40 +146,51 @@ SKIP: {
|
|||
my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
|
||||
my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
|
||||
my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts));
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_http -C 1 www.verisign.com");
|
||||
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' just expired/, "Output on expire date");
|
||||
is( $res->return_code, 2, "Output on expire date" );
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date");
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./check_http -C 1 www.verisign.com");
|
||||
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 0 minutes/, "cert expires in 1 second output");
|
||||
is( $res->return_code, 2, "cert expires in 1 second exit code" );
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output");
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./check_http -C 1 www.verisign.com");
|
||||
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 minutes/, "cert expires in 2 minutes output");
|
||||
is( $res->return_code, 2, "cert expires in 2 minutes exit code" );
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output");
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./check_http -C 1 www.verisign.com");
|
||||
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 hours/, "cert expires in 2 hours output");
|
||||
is( $res->return_code, 2, "cert expires in 2 hours exit code" );
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output");
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_http -C 1 www.verisign.com");
|
||||
like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expired on/, "Certificate expired output");
|
||||
is( $res->return_code, 2, "Certificate expired exit code" );
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output");
|
||||
};
|
||||
|
||||
$res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" );
|
||||
$res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -E" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
|
||||
|
||||
$res = NPTest->testCmd(
|
||||
"./check_http --ssl -H www.e-paycobalt.com"
|
||||
"./$plugin --ssl -H www.e-paycobalt.com"
|
||||
);
|
||||
cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
|
||||
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" );
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
|
||||
is( $res->return_code, 0, "Redirection based on location is okay");
|
||||
|
||||
$res = NPTest->testCmd( "./check_http -H www.mozilla.com --extended-perfdata" );
|
||||
$res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "No internet access or proxy configured", 6 if $internet_access eq "no" or ! $host_tcp_proxy;
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302");
|
||||
is( $res->return_code, 0, "Proxy HTTP works");
|
||||
like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT");
|
||||
is( $res->return_code, 0, "Proxy HTTP CONNECT works");
|
||||
like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD");
|
||||
is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method");
|
||||
like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent");
|
||||
}
|
||||
|
|
|
@ -8,17 +8,10 @@ use strict;
|
|||
use Test::More tests => 7;
|
||||
use NPTest;
|
||||
|
||||
my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost",
|
||||
"A host providing an STMP Service (a mail server)");
|
||||
|
||||
my $host_tcp_imap = getTestParameter( "host_tcp_imap", "NP_HOST_TCP_IMAP", $host_tcp_smtp,
|
||||
"A host providing an IMAP Service (a mail server)");
|
||||
|
||||
my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
my $host_tcp_smtp = getTestParameter("NP_HOST_TCP_SMTP", "A host providing an STMP Service (a mail server)", "mailhost");
|
||||
my $host_tcp_imap = getTestParameter("NP_HOST_TCP_IMAP", "A host providing an IMAP Service (a mail server)", $host_tcp_smtp);
|
||||
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");
|
||||
|
||||
my $t;
|
||||
|
||||
|
|
|
@ -10,23 +10,9 @@ use NPTest;
|
|||
|
||||
plan tests => 10;
|
||||
|
||||
my $host_tcp_jabber = getTestParameter(
|
||||
"NP_HOST_TCP_JABBER",
|
||||
"A host providing the Jabber Service",
|
||||
"jabber.org"
|
||||
);
|
||||
|
||||
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",
|
||||
);
|
||||
my $host_tcp_jabber = getTestParameter("NP_HOST_TCP_JABBER", "A host providing the Jabber Service", "jabber.de");
|
||||
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");
|
||||
|
||||
|
||||
my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/';
|
||||
|
|
|
@ -9,19 +9,10 @@ use warnings;
|
|||
use Test::More;
|
||||
use NPTest;
|
||||
|
||||
my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP",
|
||||
"A host providing the LDAP Service",
|
||||
"localhost" );
|
||||
|
||||
my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN",
|
||||
"A base dn for the LDAP Service",
|
||||
"cn=admin" );
|
||||
|
||||
my $host_nonresponsive = getTestParameter("host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
|
||||
my $hostname_invalid = getTestParameter("hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP", "A host providing the LDAP Service", "localhost");
|
||||
my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN", "A base dn for the LDAP Service", "cn=admin");
|
||||
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");
|
||||
|
||||
my($result, $cmd);
|
||||
my $command = './check_ldap';
|
||||
|
|
|
@ -21,30 +21,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
|
|||
plan tests => 15;
|
||||
|
||||
my $bad_login_output = '/Access denied for user /';
|
||||
my $mysqlserver = getTestParameter(
|
||||
"NP_MYSQL_SERVER",
|
||||
"A MySQL Server hostname or IP with no slaves setup"
|
||||
);
|
||||
my $mysqlsocket = getTestParameter(
|
||||
"NP_MYSQL_SOCKET",
|
||||
"Full path to a MySQL Server socket with no slaves setup"
|
||||
);
|
||||
my $mysql_login_details = getTestParameter(
|
||||
"MYSQL_LOGIN_DETAILS",
|
||||
"Command line parameters to specify login access (requires " .
|
||||
"REPLICATION CLIENT privleges)",
|
||||
"-u test -ptest",
|
||||
);
|
||||
my $with_slave = getTestParameter(
|
||||
"NP_MYSQL_WITH_SLAVE",
|
||||
"MySQL server with slaves setup"
|
||||
);
|
||||
my $with_slave_login = getTestParameter(
|
||||
"NP_MYSQL_WITH_SLAVE_LOGIN",
|
||||
"Login details for server with slave (requires REPLICATION CLIENT " .
|
||||
"privleges)",
|
||||
$mysql_login_details || "-u test -ptest"
|
||||
);
|
||||
my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup");
|
||||
my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup");
|
||||
my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privleges)", "-u test -ptest");
|
||||
my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup");
|
||||
my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privleges)", $mysql_login_details || "-u test -ptest");
|
||||
|
||||
my $result;
|
||||
|
||||
|
|
|
@ -17,15 +17,8 @@ use vars qw($tests);
|
|||
|
||||
plan skip_all => "check_mysql_query not compiled" unless (-x "check_mysql_query");
|
||||
|
||||
my $mysqlserver = getTestParameter(
|
||||
"NP_MYSQL_SERVER",
|
||||
"A MySQL Server with no slaves setup"
|
||||
);
|
||||
my $mysql_login_details = getTestParameter(
|
||||
"MYSQL_LOGIN_DETAILS",
|
||||
"Command line parameters to specify login access",
|
||||
"-u user -ppw -d db",
|
||||
);
|
||||
my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server with no slaves setup");
|
||||
my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access", "-u user -ppw -d db");
|
||||
my $result;
|
||||
|
||||
if (! $mysqlserver) {
|
||||
|
|
|
@ -15,18 +15,12 @@ BEGIN {
|
|||
|
||||
my $res;
|
||||
|
||||
my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost",
|
||||
"A host providing an SNMP Service");
|
||||
my $host_snmp = getTestParameter("NP_HOST_SNMP", "A host providing an SNMP Service", "localhost");
|
||||
my $snmp_community = getTestParameter("NP_SNMP_COMMUNITY", "The SNMP Community string for SNMP Testing (assumes snmp v1)", "public");
|
||||
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");
|
||||
my $user_snmp = getTestParameter("NP_SNMP_USER", "An SNMP user", "auth_md5");
|
||||
|
||||
my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public",
|
||||
"The SNMP Community string for SNMP Testing (assumes snmp v1)" );
|
||||
|
||||
my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
my $user_snmp = getTestParameter( "user_snmp", "NP_SNMP_USER", "auth_md5", "An SNMP user");
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -t 1" );
|
||||
is( $res->return_code, 3, "No host name" );
|
||||
|
@ -154,9 +148,9 @@ SKIP: {
|
|||
cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
|
||||
like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
|
||||
|
||||
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunParameters.1");
|
||||
cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
|
||||
is( $res->output, 'SNMP OK - "" | ', "snmp response without datatype" );
|
||||
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1");
|
||||
cmp_ok( $res->return_code, '==', 0, "snmp response without datatype");
|
||||
like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" );
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
|
|
|
@ -9,17 +9,9 @@ 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" );
|
||||
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;
|
||||
|
|
|
@ -15,18 +15,11 @@ BEGIN {
|
|||
}
|
||||
|
||||
|
||||
my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost",
|
||||
"A host providing the HTTP Service (a web server)" );
|
||||
|
||||
my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
|
||||
my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
|
||||
"Is this system directly connected to the internet?",
|
||||
"yes");
|
||||
my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
|
||||
my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "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");
|
||||
my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes");
|
||||
|
||||
my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/';
|
||||
|
||||
|
@ -42,10 +35,10 @@ $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2
|
|||
$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 );
|
||||
$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 );
|
||||
if($internet_access ne "no") {
|
||||
$t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 );
|
||||
$t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 );
|
||||
$t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 );
|
||||
$t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 );
|
||||
$t += checkCmd( "./check_tcp -S -D 1 -H $host_tls_http -p 443", 0 );
|
||||
$t += checkCmd( "./check_tcp -S -D 9000,1 -H $host_tls_http -p 443", 1 );
|
||||
$t += checkCmd( "./check_tcp -S -D 9000 -H $host_tls_http -p 443", 1 );
|
||||
$t += checkCmd( "./check_tcp -S -D 9000,8999 -H $host_tls_http -p 443", 2 );
|
||||
}
|
||||
|
||||
# Need the \r\n to make it more standards compliant with web servers. Need the various quotes
|
||||
|
|
|
@ -11,14 +11,9 @@ use NPTest;
|
|||
use vars qw($tests);
|
||||
BEGIN {$tests = 8; plan tests => $tests}
|
||||
|
||||
my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost",
|
||||
"A host providing the UDP Time Service" );
|
||||
|
||||
my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
|
||||
"The hostname of system not responsive to network requests" );
|
||||
|
||||
my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
|
||||
"An invalid (not known to DNS) hostname" );
|
||||
my $host_udp_time = getTestParameter("NP_HOST_UDP_TIME", "A host providing the UDP Time 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");
|
||||
|
||||
my $successOutput = '/^TIME OK - [0-9]+ second time difference/';
|
||||
|
||||
|
|
|
@ -34,12 +34,12 @@ 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';
|
||||
}
|
||||
elsif(system("which netcat >/dev/null 2>&1") == 0) {
|
||||
$nc = 'netcat -w 3 -l -u -p 3333';
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "solaris netcat does not listen to udp", 6 if $^O eq 'solaris';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue