summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-10-12 13:58:43 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-10-12 13:58:43 (GMT)
commitbd9a612f6c18fcc9b17e5abf58def18b19521d82 (patch)
treec4bb4e93ccbca424b2bd7aeb2a6ad799bc3e3791
parentcff53455ffc4d4df7214f8d671b3dca7ca26f51d (diff)
downloadmonitoring-plugins-bd9a612f6c18fcc9b17e5abf58def18b19521d82.tar.gz
Fixed output from -e in check_disk (Andreas Behal)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1490 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--NPTest.pm7
-rw-r--r--THANKS.in1
-rw-r--r--plugins/check_disk.c16
-rw-r--r--plugins/t/check_disk.t13
4 files changed, 30 insertions, 7 deletions
diff --git a/NPTest.pm b/NPTest.pm
index 1372d14..432f396 100644
--- a/NPTest.pm
+++ b/NPTest.pm
@@ -603,6 +603,13 @@ sub perf_output {
603 return $1 || ""; 603 return $1 || "";
604} 604}
605 605
606sub only_output {
607 my $self = shift;
608 $_ = $self->{output};
609 /(.*?)\|/;
610 return $1 || "";
611}
612
606sub testCmd { 613sub testCmd {
607 my $class = shift; 614 my $class = shift;
608 my $command = shift or die "No command passed to testCmd"; 615 my $command = shift or die "No command passed to testCmd";
diff --git a/THANKS.in b/THANKS.in
index 5cdcdf7..5bc5208 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -191,3 +191,4 @@ Lance Albertson
191Nathan Vonnahme 191Nathan Vonnahme
192Mike Emigh 192Mike Emigh
193Christian Mies 193Christian Mies
194Andreas Behal
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index b546fd2..b9787c8 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -206,6 +206,10 @@ main (int argc, char **argv)
206 206
207 /* Process for every path in list */ 207 /* Process for every path in list */
208 for (path = path_select_list; path; path=path->name_next) { 208 for (path = path_select_list; path; path=path->name_next) {
209
210 /* reset disk result */
211 disk_result = STATE_UNKNOWN;
212
209 me = path->best_match; 213 me = path->best_match;
210 214
211 /* Filters */ 215 /* Filters */
@@ -258,23 +262,25 @@ main (int argc, char **argv)
258 262
259 temp_result = get_status(dfree_units, path->freespace_units); 263 temp_result = get_status(dfree_units, path->freespace_units);
260 if (verbose >=3) printf("Freespace_units result=%d\n", temp_result); 264 if (verbose >=3) printf("Freespace_units result=%d\n", temp_result);
261 result = max_state( result, temp_result ); 265 disk_result = max_state( disk_result, temp_result );
262 266
263 temp_result = get_status(dfree_pct, path->freespace_percent); 267 temp_result = get_status(dfree_pct, path->freespace_percent);
264 if (verbose >=3) printf("Freespace%% result=%d\n", temp_result); 268 if (verbose >=3) printf("Freespace%% result=%d\n", temp_result);
265 result = max_state( result, temp_result ); 269 disk_result = max_state( disk_result, temp_result );
266 270
267 temp_result = get_status(dused_units, path->usedspace_units); 271 temp_result = get_status(dused_units, path->usedspace_units);
268 if (verbose >=3) printf("Usedspace_units result=%d\n", temp_result); 272 if (verbose >=3) printf("Usedspace_units result=%d\n", temp_result);
269 result = max_state( result, temp_result ); 273 disk_result = max_state( disk_result, temp_result );
270 274
271 temp_result = get_status(dused_pct, path->usedspace_percent); 275 temp_result = get_status(dused_pct, path->usedspace_percent);
272 if (verbose >=3) printf("Usedspace_percent result=%d\n", temp_result); 276 if (verbose >=3) printf("Usedspace_percent result=%d\n", temp_result);
273 result = max_state( result, temp_result ); 277 disk_result = max_state( disk_result, temp_result );
274 278
275 temp_result = get_status(dused_inodes_percent, path->usedinodes_percent); 279 temp_result = get_status(dused_inodes_percent, path->usedinodes_percent);
276 if (verbose >=3) printf("Usedinodes_percent result=%d\n", temp_result); 280 if (verbose >=3) printf("Usedinodes_percent result=%d\n", temp_result);
277 result = max_state( result, temp_result ); 281 disk_result = max_state( disk_result, temp_result );
282
283 result = max_state(result, disk_result);
278 284
279 asprintf (&perf, "%s %s", perf, 285 asprintf (&perf, "%s %s", perf,
280 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 286 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 6634492..0fe87aa 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -22,7 +22,7 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
22if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { 22if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
23 plan skip_all => "Need 2 mountpoints to test"; 23 plan skip_all => "Need 2 mountpoints to test";
24} else { 24} else {
25 plan tests => 35; 25 plan tests => 39;
26} 26}
27 27
28$result = NPTest->testCmd( 28$result = NPTest->testCmd(
@@ -85,6 +85,16 @@ $result = NPTest->testCmd(
85 "./check_disk -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free" 85 "./check_disk -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
86 ); 86 );
87cmp_ok( $result->return_code, "==", 1, "Combining above two tests, get warning"); 87cmp_ok( $result->return_code, "==", 1, "Combining above two tests, get warning");
88my $all_disks = $result->output;
89
90$result = NPTest->testCmd(
91 "./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
92 );
93isnt( $result->output, $all_disks, "-e gives different output");
94like( $result->output, qr/$less_free/, "Found problem $less_free");
95unlike( $result->only_output, qr/$more_free/, "Has ignored $more_free as not a problem");
96like( $result->perf_output, qr/$more_free/, "But $more_free is still in perf data");
97
88 98
89 99
90 100
@@ -97,7 +107,6 @@ $result = NPTest->testCmd(
97 "./check_disk -w $avg_free% -c $avg_free% -p $less_free" 107 "./check_disk -w $avg_free% -c $avg_free% -p $less_free"
98 ); 108 );
99cmp_ok( $result->return_code, '==', 2, "Get critical on less_free, checking avg_free"); 109cmp_ok( $result->return_code, '==', 2, "Get critical on less_free, checking avg_free");
100
101$result = NPTest->testCmd( 110$result = NPTest->testCmd(
102 "./check_disk -w $avg_free% -c 0% -p $more_free -w $avg_free% -c $avg_free% -p $less_free" 111 "./check_disk -w $avg_free% -c 0% -p $more_free -w $avg_free% -c $avg_free% -p $less_free"
103 ); 112 );