summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cff5345)
raw | patch | inline | side by side (parent: cff5345)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 12 Oct 2006 13:58:43 +0000 (13:58 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 12 Oct 2006 13:58:43 +0000 (13:58 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1490 f882894a-f735-0410-b71e-b25c423dba1c
NPTest.pm | patch | blob | history | |
THANKS.in | patch | blob | history | |
plugins/check_disk.c | patch | blob | history | |
plugins/t/check_disk.t | patch | blob | history |
diff --git a/NPTest.pm b/NPTest.pm
index 1372d1423042bcaf0357f77367679cd6ccf08aad..432f3968cec95bd351f43ed4e990067b1e6e0fce 100644 (file)
--- a/NPTest.pm
+++ b/NPTest.pm
return $1 || "";
}
+sub only_output {
+ my $self = shift;
+ $_ = $self->{output};
+ /(.*?)\|/;
+ return $1 || "";
+}
+
sub testCmd {
my $class = shift;
my $command = shift or die "No command passed to testCmd";
diff --git a/THANKS.in b/THANKS.in
index 5cdcdf71a250473d66e581ce6942f82b3da5e230..5bc52088ef05eb49b48f37c2b9fa6b3be59d2203 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
Nathan Vonnahme
Mike Emigh
Christian Mies
+Andreas Behal
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index b546fd2ff9febd0971642d60579c3dcceb879124..b9787c89ecd952caa84966dc40b13f0232ebd783 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
/* Process for every path in list */
for (path = path_select_list; path; path=path->name_next) {
+
+ /* reset disk result */
+ disk_result = STATE_UNKNOWN;
+
me = path->best_match;
/* Filters */
temp_result = get_status(dfree_units, path->freespace_units);
if (verbose >=3) printf("Freespace_units result=%d\n", temp_result);
- result = max_state( result, temp_result );
+ disk_result = max_state( disk_result, temp_result );
temp_result = get_status(dfree_pct, path->freespace_percent);
if (verbose >=3) printf("Freespace%% result=%d\n", temp_result);
- result = max_state( result, temp_result );
+ disk_result = max_state( disk_result, temp_result );
temp_result = get_status(dused_units, path->usedspace_units);
if (verbose >=3) printf("Usedspace_units result=%d\n", temp_result);
- result = max_state( result, temp_result );
+ disk_result = max_state( disk_result, temp_result );
temp_result = get_status(dused_pct, path->usedspace_percent);
if (verbose >=3) printf("Usedspace_percent result=%d\n", temp_result);
- result = max_state( result, temp_result );
+ disk_result = max_state( disk_result, temp_result );
temp_result = get_status(dused_inodes_percent, path->usedinodes_percent);
if (verbose >=3) printf("Usedinodes_percent result=%d\n", temp_result);
- result = max_state( result, temp_result );
+ disk_result = max_state( disk_result, temp_result );
+
+ result = max_state(result, disk_result);
asprintf (&perf, "%s %s", perf,
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 6634492726f3accc59b7c8ecb3e1a76f78b3b04c..0fe87aa38c55db7f3f7848efb6b4906bc6dd733d 100644 (file)
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
plan skip_all => "Need 2 mountpoints to test";
} else {
- plan tests => 35;
+ plan tests => 39;
}
$result = NPTest->testCmd(
"./check_disk -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
);
cmp_ok( $result->return_code, "==", 1, "Combining above two tests, get warning");
+my $all_disks = $result->output;
+
+$result = NPTest->testCmd(
+ "./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
+ );
+isnt( $result->output, $all_disks, "-e gives different output");
+like( $result->output, qr/$less_free/, "Found problem $less_free");
+unlike( $result->only_output, qr/$more_free/, "Has ignored $more_free as not a problem");
+like( $result->perf_output, qr/$more_free/, "But $more_free is still in perf data");
+
"./check_disk -w $avg_free% -c $avg_free% -p $less_free"
);
cmp_ok( $result->return_code, '==', 2, "Get critical on less_free, checking avg_free");
-
$result = NPTest->testCmd(
"./check_disk -w $avg_free% -c 0% -p $more_free -w $avg_free% -c $avg_free% -p $less_free"
);