diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-12-20 19:25:59 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-12-20 19:25:59 +0000 |
commit | 958162b45fb77dcacb302e6c65cc5fb45df47692 (patch) | |
tree | c1f1a55635db7bf38d071f6acbb1a5ad2060b084 /plugins/t/check_disk.t | |
parent | ff2e8114a43f506133755c1f8222b47601b709e3 (diff) | |
download | monitoring-plugins-958162b45fb77dcacb302e6c65cc5fb45df47692.tar.gz |
Fixed inode thresholds, regressed from previous release
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1554 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t/check_disk.t')
-rw-r--r-- | plugins/t/check_disk.t | 73 |
1 files changed, 66 insertions, 7 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index e8e35b9f..dd4fcee4 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -24,13 +24,13 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth | |||
24 | if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { | 24 | if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { |
25 | plan skip_all => "Need 2 mountpoints to test"; | 25 | plan skip_all => "Need 2 mountpoints to test"; |
26 | } else { | 26 | } else { |
27 | plan tests => 42; | 27 | plan tests => 56; |
28 | } | 28 | } |
29 | 29 | ||
30 | $result = NPTest->testCmd( | 30 | $result = NPTest->testCmd( |
31 | "./check_disk -w 1% -c 1% -p $mountpoint_valid -w 1% -c 1% -p $mountpoint2_valid" | 31 | "./check_disk -w 1% -c 1% -p $mountpoint_valid -w 1% -c 1% -p $mountpoint2_valid" |
32 | ); | 32 | ); |
33 | cmp_ok( $result->return_code, "==", 0, "Checking two mountpoints (must have at least 1% free)"); | 33 | cmp_ok( $result->return_code, "==", 0, "Checking two mountpoints (must have at least 1% free in space and inodes)"); |
34 | my $c = 0; | 34 | my $c = 0; |
35 | $_ = $result->output; | 35 | $_ = $result->output; |
36 | $c++ while /\(/g; # counts number of "(" - should be two | 36 | $c++ while /\(/g; # counts number of "(" - should be two |
@@ -54,6 +54,26 @@ if ($free_on_mp1 > $free_on_mp2) { | |||
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | # Do same for inodes | ||
58 | $_ = $result->output; | ||
59 | my ($free_inode_on_mp1, $free_inode_on_mp2) = (m/inode=(\d+)%.*inode=(\d+)%/); | ||
60 | die "Cannot parse free inodes: $_" unless ($free_inode_on_mp1 && $free_inode_on_mp2); | ||
61 | my $avg_inode_free = ceil(($free_inode_on_mp1 + $free_inode_on_mp2)/2); | ||
62 | my ($more_inode_free, $less_inode_free); | ||
63 | if ($free_inode_on_mp1 > $free_inode_on_mp2) { | ||
64 | $more_inode_free = $mountpoint_valid; | ||
65 | $less_inode_free = $mountpoint2_valid; | ||
66 | } elsif ($free_on_mp1 < $free_on_mp2) { | ||
67 | $more_inode_free = $mountpoint2_valid; | ||
68 | $less_inode_free = $mountpoint_valid; | ||
69 | } else { | ||
70 | die "Two mountpoints with same inodes free - cannot do rest of test"; | ||
71 | } | ||
72 | |||
73 | |||
74 | |||
75 | # Basic filesystem checks for sizes | ||
76 | |||
57 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" ); | 77 | $result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" ); |
58 | cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free"); | 78 | cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free"); |
59 | like ( $result->output, $successOutput, "OK output" ); | 79 | like ( $result->output, $successOutput, "OK output" ); |
@@ -76,8 +96,6 @@ cmp_ok( $result->return_code, "==", 2, "Get critical on less_free mountpoint $le | |||
76 | like( $result->output, $failureOutput, "Right output" ); | 96 | like( $result->output, $failureOutput, "Right output" ); |
77 | 97 | ||
78 | 98 | ||
79 | |||
80 | |||
81 | $result = NPTest->testCmd( | 99 | $result = NPTest->testCmd( |
82 | "./check_disk -w $avg_free% -c 0% -p $less_free" | 100 | "./check_disk -w $avg_free% -c 0% -p $less_free" |
83 | ); | 101 | ); |
@@ -102,9 +120,6 @@ like( $result->output, qr/$less_free/, "Found problem $less_free"); | |||
102 | unlike( $result->only_output, qr/$more_free/, "Has ignored $more_free as not a problem"); | 120 | unlike( $result->only_output, qr/$more_free/, "Has ignored $more_free as not a problem"); |
103 | like( $result->perf_output, qr/$more_free/, "But $more_free is still in perf data"); | 121 | like( $result->perf_output, qr/$more_free/, "But $more_free is still in perf data"); |
104 | 122 | ||
105 | |||
106 | |||
107 | |||
108 | $result = NPTest->testCmd( | 123 | $result = NPTest->testCmd( |
109 | "./check_disk -w $avg_free% -c 0% -p $more_free" | 124 | "./check_disk -w $avg_free% -c 0% -p $more_free" |
110 | ); | 125 | ); |
@@ -126,6 +141,50 @@ cmp_ok( $result->return_code, '==', 2, "And reversing arguments should not make | |||
126 | 141 | ||
127 | 142 | ||
128 | 143 | ||
144 | # Basic inode checks for sizes | ||
145 | |||
146 | $result = NPTest->testCmd( "./check_disk --icritical 1% --iwarning 1% -p $more_inode_free" ); | ||
147 | is( $result->return_code, 0, "At least 1% free on inodes for both mountpoints"); | ||
148 | |||
149 | $result = NPTest->testCmd( "./check_disk -K 100% -W 100% -p $less_inode_free" ); | ||
150 | is( $result->return_code, 2, "Critical requesting 100% free inodes for both mountpoints"); | ||
151 | |||
152 | $result = NPTest->testCmd( "./check_disk --iwarning 1% --icritical 1% -p $more_inode_free -K 100% -W 100% -p $less_inode_free" ); | ||
153 | is( $result->return_code, 2, "Get critical on less_inode_free mountpoint $less_inode_free"); | ||
154 | |||
155 | $result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $less_inode_free" ); | ||
156 | is( $result->return_code, 1, "Get warning on less_inode_free, when checking average"); | ||
157 | |||
158 | $result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free "); | ||
159 | is( $result->return_code, 0, "Get ok on more_inode_free when checking average"); | ||
160 | |||
161 | $result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $less_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free" ); | ||
162 | is ($result->return_code, 1, "Combine above two tests, get warning"); | ||
163 | $all_disks = $result->output; | ||
164 | |||
165 | $result = NPTest->testCmd( "./check_disk -e -W $avg_inode_free% -K 0% -p $less_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $more_inode_free" ); | ||
166 | isnt( $result->output, $all_disks, "-e gives different output"); | ||
167 | like( $result->output, qr/$less_inode_free/, "Found problem $less_inode_free"); | ||
168 | unlike( $result->only_output, qr/$more_inode_free/, "Has ignored $more_inode_free as not a problem"); | ||
169 | like( $result->perf_output, qr/$more_inode_free/, "But $more_inode_free is still in perf data"); | ||
170 | |||
171 | $result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $more_inode_free" ); | ||
172 | is( $result->return_code, 0, "Get ok on more_inode_free mountpoint, checking average"); | ||
173 | |||
174 | $result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free" ); | ||
175 | is( $result->return_code, 2, "Get critical on less_inode_free, checking average"); | ||
176 | |||
177 | $result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K 0% -p $more_inode_free -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free" ); | ||
178 | is( $result->return_code, 2, "Combining above two tests, get critical"); | ||
179 | |||
180 | $result = NPTest->testCmd( "./check_disk -W $avg_inode_free% -K $avg_inode_free% -p $less_inode_free -W $avg_inode_free% -K 0% -p $more_inode_free" ); | ||
181 | cmp_ok( $result->return_code, '==', 2, "And reversing arguments should not make a difference"); | ||
182 | |||
183 | |||
184 | |||
185 | |||
186 | |||
187 | |||
129 | TODO: { | 188 | TODO: { |
130 | local $TODO = "Invalid percent figures"; | 189 | local $TODO = "Invalid percent figures"; |
131 | $result = NPTest->testCmd( | 190 | $result = NPTest->testCmd( |