summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/NPTest.cache.travis56
-rw-r--r--plugins/t/check_dns.t3
-rw-r--r--plugins/t/check_fping.t14
-rw-r--r--plugins/t/check_hpjd.t35
-rw-r--r--plugins/t/check_jabber.t6
-rw-r--r--plugins/t/check_ntp.t14
-rw-r--r--plugins/t/check_procs.t2
-rw-r--r--plugins/t/check_snmp.t2
-rw-r--r--plugins/t/check_udp.t2
9 files changed, 107 insertions, 27 deletions
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis
new file mode 100644
index 0000000..4ebfb90
--- /dev/null
+++ b/plugins/t/NPTest.cache.travis
@@ -0,0 +1,56 @@
1{
2 'MYSQL_LOGIN_DETAILS' => '-u root -d test',
3 'NP_ALLOW_SUDO' => 'yes',
4 'NP_DNS_SERVER' => '8.8.8.8',
5 'NP_GOOD_NTP_SERVICE' => '',
6 'NP_HOSTNAME_INVALID' => 'nosuchhost',
7 'NP_HOSTNAME_VALID' => 'monitoringplugins.org',
8 'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
9 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
10 'NP_HOST_DHCP_RESPONSIVE' => '',
11 'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
12 'NP_HOST_RESPONSIVE' => 'localhost',
13 'NP_HOST_SMB' => '',
14 'NP_HOST_SNMP' => '',
15 'NP_HOST_TCP_FTP' => '',
16 'NP_HOST_TCP_HPJD' => '',
17 'NP_HOST_HPJD_PORT_INVALID' => '161',
18 'NP_HOST_HPJD_PORT_VALID' => '',
19 'NP_HOST_TCP_HTTP' => 'localhost',
20 'NP_HOST_TCP_HTTP2' => 'labs.consol.de',
21 'NP_HOST_TCP_IMAP' => 'imap.web.de',
22 'NP_HOST_TCP_POP' => 'pop.web.de',
23 'NP_HOST_TCP_SMTP' => 'localhost',
24 'NP_HOST_TCP_SMTP_NOTLS' => '',
25 'NP_HOST_TCP_SMTP_TLS' => '',
26 'NP_INTERNET_ACCESS' => 'yes',
27 'NP_MOUNTPOINT2_VALID' => '',
28 'NP_MOUNTPOINT_VALID' => '/',
29 'NP_MYSQL_SERVER' => 'localhost',
30 'NP_HOST_UDP_TIME' => 'localhost',
31 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock',
32 'NP_MYSQL_WITH_SLAVE' => '',
33 'NP_MYSQL_WITH_SLAVE_LOGIN' => '',
34 'NP_NO_NTP_SERVICE' => 'localhost',
35 'NP_SMB_SHARE' => '',
36 'NP_SMB_SHARE_DENY' => '',
37 'NP_SMB_SHARE_SPC' => '',
38 'NP_SMB_VALID_USER' => '',
39 'NP_SMB_VALID_USER_PASS' => '',
40 'NP_SNMP_COMMUNITY' => '',
41 'NP_SSH_CONFIGFILE' => '~/.ssh/config',
42 'NP_SSH_HOST' => 'localhost',
43 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa',
44 'NP_HOST_TCP_JABBER' => 'jabber.org',
45 'host_nonresponsive' => '10.0.0.1',
46 'host_responsive' => 'localhost',
47 'host_snmp' => '',
48 'host_tcp_ftp' => '',
49 'host_tcp_http' => 'localhost',
50 'host_tcp_imap' => 'imap.nierlein.de',
51 'host_tcp_smtp' => 'localhost',
52 'hostname_invalid' => 'nosuchhost',
53 'snmp_community' => '',
54 'user_snmp' => '',
55 'host_udp_time' => 'none',
56}
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index 2c903db..b885880 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,7 +10,7 @@ use NPTest;
10 10
11plan skip_all => "check_dns not compiled" unless (-x "check_dns"); 11plan skip_all => "check_dns not compiled" unless (-x "check_dns");
12 12
13plan tests => 13; 13plan tests => 14;
14 14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; 15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
16 16
@@ -54,6 +54,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed");
54 54
55$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); 55$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5");
56cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); 56cmp_ok( $res->return_code, '==', 1, "Warning threshold passed");
57like( $res->output, '/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/', "Output performance data OK" );
57 58
58$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); 59$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1");
59cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); 60cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid");
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t
index 45a9be8..08692e4 100644
--- a/plugins/t/check_fping.t
+++ b/plugins/t/check_fping.t
@@ -27,16 +27,18 @@ my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_IN
27 27
28my $t; 28my $t;
29 29
30if ( -x "./check_fping" ) 30my $fping = qx(which fping 2> /dev/null);
31{ 31chomp($fping);
32if( ! -x "./check_fping") {
33 $t += skipMissingCmd( "./check_fping", $tests );
34}
35elsif ( $> != 0 && (!$fping || ! -u $fping)) {
36 $t += skipMsg( "./check_fping", $tests );
37} else {
32 $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); 38 $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput );
33 $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); 39 $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] );
34 $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); 40 $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] );
35} 41}
36else
37{
38 $t += skipMissingCmd( "./check_fping", $tests );
39}
40 42
41exit(0) if defined($Test::Harness::VERSION); 43exit(0) if defined($Test::Harness::VERSION);
42exit($tests - $t); 44exit($tests - $t);
diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t
index 10ded54..4d64852 100644
--- a/plugins/t/check_hpjd.t
+++ b/plugins/t/check_hpjd.t
@@ -10,7 +10,6 @@ use NPTest;
10 10
11plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); 11plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
12 12
13plan tests => 5;
14 13
15my $successOutput = '/^Printer ok - /'; 14my $successOutput = '/^Printer ok - /';
16my $failureOutput = '/Timeout: No [Rr]esponse from /'; 15my $failureOutput = '/Timeout: No [Rr]esponse from /';
@@ -20,31 +19,53 @@ my $host_tcp_hpjd = getTestParameter(
20 "A host (usually a printer) providing the HP-JetDirect Services" 19 "A host (usually a printer) providing the HP-JetDirect Services"
21 ); 20 );
22 21
22my $host_hpjd_port_invalid = getTestParameter(
23 "NP_HOST_HPJD_PORT_INVALID",
24 "A port that HP-JetDirect Services is not listening on",
25 "162"
26 );
27
28my $host_hpjd_port_valid = getTestParameter(
29 "NP_HOST_HPJD_PORT_VALID",
30 "The port that HP-JetDirect Services is currently listening on",
31 "161"
32 );
33
23my $host_nonresponsive = getTestParameter( 34my $host_nonresponsive = getTestParameter(
24 "NP_HOST_NONRESPONSIVE", 35 "NP_HOST_NONRESPONSIVE",
25 "The hostname of system not responsive to network requests", 36 "The hostname of system not responsive to network requests",
26 "10.0.0.1", 37 "10.0.0.1"
27 ); 38 );
28 39
29my $hostname_invalid = getTestParameter( 40my $hostname_invalid = getTestParameter(
30 "NP_HOSTNAME_INVALID", 41 "NP_HOSTNAME_INVALID",
31 "An invalid (not known to DNS) hostname", 42 "An invalid (not known to DNS) hostname",
32 "nosuchhost", 43 "nosuchhost"
33 ); 44 );
34 45
46my $tests = $host_tcp_hpjd ? 9 : 5;
47plan tests => $tests;
35my $res; 48my $res;
36 49
37SKIP: { 50SKIP: {
38 skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd; 51 skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd;
39 $res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd"); 52 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd");
40 cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" ); 53 cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding" );
41 like ( $res->output, $successOutput, "Output correct" ); 54 like ( $res->output, $successOutput, "Output correct" );
55
56 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_valid");
57 cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding on port $host_hpjd_port_valid" );
58 like ( $res->output, $successOutput, "Output correct" );
59
60 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_invalid");
61 cmp_ok( $res->return_code, 'eq', 2, "Jetdirect not responding on port $host_hpjd_port_invalid" );
62 like ( $res->output, $failureOutput, "Output correct" );
42} 63}
43 64
44$res = NPTest->testCmd("./check_hpjd $host_nonresponsive"); 65$res = NPTest->testCmd("./check_hpjd -H $host_nonresponsive");
45cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); 66cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
46like ( $res->output, $failureOutput, "Output OK" ); 67like ( $res->output, $failureOutput, "Output OK" );
47 68
48$res = NPTest->testCmd("./check_hpjd $hostname_invalid"); 69$res = NPTest->testCmd("./check_hpjd -H $hostname_invalid");
49cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); 70cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");
50 71
diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t
index 1aaf812..7a708d5 100644
--- a/plugins/t/check_jabber.t
+++ b/plugins/t/check_jabber.t
@@ -29,7 +29,7 @@ my $hostname_invalid = getTestParameter(
29 ); 29 );
30 30
31 31
32my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/'; 32my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/';
33 33
34my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/'; 34my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/';
35 35
@@ -40,7 +40,7 @@ my $r;
40SKIP: { 40SKIP: {
41 skip "No jabber server defined", 6 unless $host_tcp_jabber; 41 skip "No jabber server defined", 6 unless $host_tcp_jabber;
42 42
43 $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber" ); 43 $r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber" );
44 is( $r->return_code, 0, "Connected okay"); 44 is( $r->return_code, 0, "Connected okay");
45 like( $r->output, $jabberOK, "Output as expected" ); 45 like( $r->output, $jabberOK, "Output as expected" );
46 46
@@ -48,7 +48,7 @@ SKIP: {
48 is( $r->return_code, 0, "Connected okay, within limits" ); 48 is( $r->return_code, 0, "Connected okay, within limits" );
49 like( $r->output, $jabberOK, "Output as expected" ); 49 like( $r->output, $jabberOK, "Output as expected" );
50 50
51 $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10" ); 51 $r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber -wt 9 -ct 9 -to 10" );
52 is( $r->return_code, 0, "Old syntax okay" ); 52 is( $r->return_code, 0, "Old syntax okay" );
53 like( $r->output, $jabberOK, "Output as expected" ); 53 like( $r->output, $jabberOK, "Output as expected" );
54 54
diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t
index 3eee6e1..b8fc8fd 100644
--- a/plugins/t/check_ntp.t
+++ b/plugins/t/check_ntp.t
@@ -23,27 +23,27 @@ my $no_ntp_service = getTestParameter( "NP_NO_NTP_SERVICE",
23 "A host NOT providing the NTP service", 23 "A host NOT providing the NTP service",
24 "localhost" ); 24 "localhost" );
25 25
26my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", 26my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
27 "The hostname of system not responsive to network requests", 27 "The hostname of system not responsive to network requests",
28 "10.0.0.1" ); 28 "10.0.0.1" );
29 29
30my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", 30my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
31 "An invalid (not known to DNS) hostname", 31 "An invalid (not known to DNS) hostname",
32 "nosuchhost"); 32 "nosuchhost");
33 33
34my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; 34my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
35my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; 35my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
36my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; 36my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
37my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; 37my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
38my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; 38my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}\s\(WARNING\),\struechimers=[0-9]+/';
39my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; 39my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+\s\(CRITICAL\),\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
40my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/'; 40my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/';
41my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/'; 41my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/';
42 42
43 43
44foreach my $plugin (@PLUGINS1) { 44foreach my $plugin (@PLUGINS1) {
45 SKIP: { 45 SKIP: {
46 skip "No NTP server defined", 1 unless $ntp_service; 46 skip "No NTP server defined", 6 unless $ntp_service;
47 $res = NPTest->testCmd( 47 $res = NPTest->testCmd(
48 "./$plugin -H $ntp_service -w 1000 -c 2000" 48 "./$plugin -H $ntp_service -w 1000 -c 2000"
49 ); 49 );
@@ -88,7 +88,7 @@ foreach my $plugin (@PLUGINS1) {
88 88
89foreach my $plugin (@PLUGINS2) { 89foreach my $plugin (@PLUGINS2) {
90 SKIP: { 90 SKIP: {
91 skip "No NTP server defined", 1 unless $ntp_service; 91 skip "No NTP server defined", 6 unless $ntp_service;
92 $res = NPTest->testCmd( 92 $res = NPTest->testCmd(
93 "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:" 93 "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:"
94 ); 94 );
diff --git a/plugins/t/check_procs.t b/plugins/t/check_procs.t
index ca4acdd..abe7284 100644
--- a/plugins/t/check_procs.t
+++ b/plugins/t/check_procs.t
@@ -26,7 +26,7 @@ $result = NPTest->testCmd( "./check_procs -w 100000 -c 100000 -s Z" );
26is( $result->return_code, 0, "Checking less than 100000 zombie processes" ); 26is( $result->return_code, 0, "Checking less than 100000 zombie processes" );
27like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" ); 27like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" );
28 28
29if(fork() == 0) { exec("sleep 7"); } # fork a test process 29if(fork() == 0) { exec("sleep 7"); } else { sleep(1) } # fork a test process in child and give child time to fork in parent
30$result = NPTest->testCmd( "./check_procs -a 'sleep 7'" ); 30$result = NPTest->testCmd( "./check_procs -a 'sleep 7'" );
31is( $result->return_code, 0, "Parent process is ignored" ); 31is( $result->return_code, 0, "Parent process is ignored" );
32like( $result->output, '/^PROCS OK: 1 process?/', "Output correct" ); 32like( $result->output, '/^PROCS OK: 1 process?/', "Output correct" );
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index c35d782..2d6c44a 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -45,7 +45,7 @@ is( $res->return_code, 3, "Invalid protocol" );
45like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); 45like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
46 46
47SKIP: { 47SKIP: {
48 skip "no snmp host defined", 38 if ( ! $host_snmp ); 48 skip "no snmp host defined", 48 if ( ! $host_snmp );
49 49
50 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); 50 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
51 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); 51 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t
index 619cadf..1f6fee7 100644
--- a/plugins/t/check_udp.t
+++ b/plugins/t/check_udp.t
@@ -62,7 +62,7 @@ SKIP: {
62 cmp_ok( $res->return_code, '==', '2', "Hung waiting for response"); 62 cmp_ok( $res->return_code, '==', '2', "Hung waiting for response");
63 like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); 63 like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message");
64 like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds"); 64 like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds");
65 my $read_nc = <NC>; 65 my $read_nc = <NC> || '';
66 close NC; 66 close NC;
67 cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); 67 cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" );
68} 68}