summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd9a612)
raw | patch | inline | side by side (parent: bd9a612)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 12 Oct 2006 14:14:48 +0000 (14:14 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 12 Oct 2006 14:14:48 +0000 (14:14 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1491 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_disk.c | patch | blob | history | |
plugins/t/check_disk.t | patch | blob | history |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index b9787c89ecd952caa84966dc40b13f0232ebd783..3c7b0ecfe714e229e3620d10482b846fdc4501df 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
char *output;
char *details;
char *perf;
+ char *preamble;
double inode_space_pct;
uintmax_t total, available, available_to_root, used;
double dfree_pct = -1, dused_pct = -1;
struct parameter_list *temp_list, *path;
struct name_list *seen = NULL;
- output = strdup (" - free space:");
+ preamble = strdup (" - free space:");
+ output = strdup ("");
details = strdup ("");
perf = strdup ("");
asprintf (&output, "%s%s", output, details);
- printf ("DISK %s%s|%s\n", state_text (result), output, perf);
+ printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf);
return result;
}
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 0fe87aa38c55db7f3f7848efb6b4906bc6dd733d..ec3d248ca31bb968862a9adaad96c882d00f44cc 100644 (file)
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
use NPTest;
use POSIX qw(ceil floor);
-my $successOutput = '/^DISK OK - /';
-my $failureOutput = '/^DISK CRITICAL - /';
-my $warningOutput = '/^DISK WARNING - /';
+my $successOutput = '/^DISK OK/';
+my $failureOutput = '/^DISK CRITICAL/';
+my $warningOutput = '/^DISK WARNING/';
my $result;
if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
plan skip_all => "Need 2 mountpoints to test";
} else {
- plan tests => 39;
+ plan tests => 42;
}
$result = NPTest->testCmd(
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" );
cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free");
like ( $result->output, $successOutput, "OK output" );
+like ( $result->only_output, qr/free space/, "Have free space text");
+like ( $result->only_output, qr/$more_free/, "Have disk name in text");
+
+$result = NPTest->testCmd( "./check_disk -e -w 1 -c 1 -p $more_free" );
+is( $result->only_output, "DISK OK", "No print out of disks with -e for OKs");
$result = NPTest->testCmd( "./check_disk 100 100 $more_free" );
cmp_ok( $result->return_code, '==', 0, "Old syntax okay" );