summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_disk.c6
-rw-r--r--plugins/t/check_disk.t13
2 files changed, 13 insertions, 6 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index b9787c8..3c7b0ec 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -153,6 +153,7 @@ main (int argc, char **argv)
153 char *output; 153 char *output;
154 char *details; 154 char *details;
155 char *perf; 155 char *perf;
156 char *preamble;
156 double inode_space_pct; 157 double inode_space_pct;
157 uintmax_t total, available, available_to_root, used; 158 uintmax_t total, available, available_to_root, used;
158 double dfree_pct = -1, dused_pct = -1; 159 double dfree_pct = -1, dused_pct = -1;
@@ -165,7 +166,8 @@ main (int argc, char **argv)
165 struct parameter_list *temp_list, *path; 166 struct parameter_list *temp_list, *path;
166 struct name_list *seen = NULL; 167 struct name_list *seen = NULL;
167 168
168 output = strdup (" - free space:"); 169 preamble = strdup (" - free space:");
170 output = strdup ("");
169 details = strdup (""); 171 details = strdup ("");
170 perf = strdup (""); 172 perf = strdup ("");
171 173
@@ -323,7 +325,7 @@ main (int argc, char **argv)
323 asprintf (&output, "%s%s", output, details); 325 asprintf (&output, "%s%s", output, details);
324 326
325 327
326 printf ("DISK %s%s|%s\n", state_text (result), output, perf); 328 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf);
327 return result; 329 return result;
328} 330}
329 331
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 0fe87aa..ec3d248 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -10,9 +10,9 @@ use Test::More;
10use NPTest; 10use NPTest;
11use POSIX qw(ceil floor); 11use POSIX qw(ceil floor);
12 12
13my $successOutput = '/^DISK OK - /'; 13my $successOutput = '/^DISK OK/';
14my $failureOutput = '/^DISK CRITICAL - /'; 14my $failureOutput = '/^DISK CRITICAL/';
15my $warningOutput = '/^DISK WARNING - /'; 15my $warningOutput = '/^DISK WARNING/';
16 16
17my $result; 17my $result;
18 18
@@ -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 => 39; 25 plan tests => 42;
26} 26}
27 27
28$result = NPTest->testCmd( 28$result = NPTest->testCmd(
@@ -55,6 +55,11 @@ if ($free_on_mp1 > $free_on_mp2) {
55$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" ); 55$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" );
56cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free"); 56cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free");
57like ( $result->output, $successOutput, "OK output" ); 57like ( $result->output, $successOutput, "OK output" );
58like ( $result->only_output, qr/free space/, "Have free space text");
59like ( $result->only_output, qr/$more_free/, "Have disk name in text");
60
61$result = NPTest->testCmd( "./check_disk -e -w 1 -c 1 -p $more_free" );
62is( $result->only_output, "DISK OK", "No print out of disks with -e for OKs");
58 63
59$result = NPTest->testCmd( "./check_disk 100 100 $more_free" ); 64$result = NPTest->testCmd( "./check_disk 100 100 $more_free" );
60cmp_ok( $result->return_code, '==', 0, "Old syntax okay" ); 65cmp_ok( $result->return_code, '==', 0, "Old syntax okay" );