summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
authorMatthias Eble <psychotrahe@users.sourceforge.net>2010-11-28 21:08:54 (GMT)
committerMatthias Eble <psychotrahe@users.sourceforge.net>2010-11-28 21:08:54 (GMT)
commit9faccbb26106fc6f134c783c91d1871af581af02 (patch)
treec515f74a7d6d739afa0c7b878e1802858465a8b3 /plugins-scripts
parent3c67c9cb60a4681a29e509fccbb333e0f6234f54 (diff)
downloadmonitoring-plugins-9faccbb26106fc6f134c783c91d1871af581af02.tar.gz
add test cases for check_disk_smb
Diffstat (limited to 'plugins-scripts')
-rw-r--r--plugins-scripts/t/check_disk_smb.t96
1 files changed, 96 insertions, 0 deletions
diff --git a/plugins-scripts/t/check_disk_smb.t b/plugins-scripts/t/check_disk_smb.t
new file mode 100644
index 0000000..bd43c9c
--- /dev/null
+++ b/plugins-scripts/t/check_disk_smb.t
@@ -0,0 +1,96 @@
1#! /usr/bin/perl -w -I ..
2#
3# test cases for check_disk_smb
4#
5
6use strict;
7use Test::More;
8use NPTest;
9
10my $tests = 14;
11plan tests => $tests;
12my $res;
13
14my $plugin = "check_disk_smb";
15SKIP: {
16 skip "$plugin is not created", $tests if ( ! -x $plugin );
17 my $auth = "";
18
19 my $host = getTestParameter("NP_HOST_SMB", "A host providing an SMB Service",
20 "localhost");
21
22 my $smb_share = getTestParameter("NP_SMB_SHARE",
23 "An SMB share name the host provides",
24 "public");
25
26 my $smb_share_spc = getTestParameter("NP_SMB_SHARE_SPC",
27 "An SMB share name containing one or more spaces the host provides",
28 "pub lic");
29
30 my $smb_share_deny = getTestParameter("NP_SMB_SHARE_DENY",
31 "An access denying SMB share name the host provides",
32 "private");
33
34 my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
35 "The hostname of system not responsive to network requests", "10.0.0.1" );
36
37 my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
38 "An invalid (not known to DNS) hostname",
39 "nosuchhost" );
40 my $user = getTestParameter( "NP_SMB_VALID_USER", "A valid smb user", "" );
41 my $pass = getTestParameter( "NP_SMB_VALID_USER_PASS", "A valid password for valid smb user", "" );
42 $auth .= "-u $user " if ($user);
43 $auth .= "-p $pass " if ($pass);
44
45
46
47 $res = NPTest->testCmd( "./$plugin" );
48 is( $res->return_code, 3, "No arguments" );
49
50 $res = NPTest->testCmd( "./$plugin -H fakehostname" );
51 is( $res->return_code, 3, "No share specified" );
52
53 $res = NPTest->testCmd( "./$plugin -H fakehostname -s share -w 100G -c 101G" );
54 is( $res->return_code, 3, "warn is less than critical" );
55
56 SKIP: {
57 skip "no smb host defined", 6 if ( ! $host );
58
59 SKIP: {
60 skip "no share name defined", 2 if ( ! $smb_share );
61 $res = NPTest->testCmd( "./$plugin -H $host $auth -s $smb_share -w 2k -c 1k" );
62 cmp_ok( $res->return_code, '==', 0, "Exit OK if $smb_share has > 1k free space");
63 like($res->output, '/free/i', "String contains the word 'free'");
64
65 $res = NPTest->testCmd( "./$plugin -H $host $auth -s $smb_share -w 10001G -c 10000G" );
66 cmp_ok( $res->return_code, '==', 2, "Exit CRIT if $smb_share has < 10000G free space");
67 like($res->output, '/free/i', "String contains the word 'free'");
68
69 $res = NPTest->testCmd( "./$plugin -H $host $auth -s $smb_share -w 10000G -c 1k" );
70 cmp_ok( $res->return_code, '==', 1, "Exit WARN if $smb_share has > 10000G and <1k free space");
71 like($res->output, '/free/i', "String contains the word 'free'");
72 }
73
74 SKIP: {
75 skip "no share name containing spaces defined", 2 if ( ! $smb_share_spc );
76 $res = NPTest->testCmd( "./$plugin -H $host $auth -s '$smb_share_spc' -w 2k -c 1k" );
77 cmp_ok( $res->return_code, '==', 0, "Exit OK if '$smb_share_spc' has > 1k free space");
78 like($res->output, '/free/i', "String contains the word 'free'");
79
80 }
81 SKIP: {
82 skip "no share name without permissions ", 2 if ( ! $smb_share_deny );
83 $res = NPTest->testCmd( "./$plugin -H $host $auth -s $smb_share_deny -w 2k -c 1k" );
84 cmp_ok( $res->return_code, '==', 2, "Exit CRIT if $smb_share_deny has > 1k free space");
85 unlike($res->output, '/free/i', "String does not contain the word 'free'");
86
87 }
88 }
89
90 SKIP: {
91 skip "no non responsive host defined", 1 if ( ! $host_nonresponsive );
92 $res = NPTest->testCmd( "./$plugin -H $host_nonresponsive -s np_foobar ");
93 cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" );
94 }
95
96}