summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorOliver Skibbe <oliskibbe@gmail.com>2016-11-21 13:49:38 +0100
committerGitHub <noreply@github.com>2016-11-21 13:49:38 +0100
commitfce769d942ec08044812b71bfa470ff26f9c0eda (patch)
treeb3b93b043032d472779ba74faed1d3500578dedb /plugins
parent8b727baec560bdd3eea8fe89b897f2adb9aa535f (diff)
parentd03a2a82b3f0108ee3d2d241a6c4628b082704bb (diff)
downloadmonitoring-plugins-fce769d942ec08044812b71bfa470ff26f9c0eda.tar.gz
Merge pull request #1446 from monitoring-plugins/revert-1436-check_disk_iss1420
Revert "check_disk - show all disks if state is ok and option error only is used"
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_disk.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 4b5ba5fe..e73a0083 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -165,7 +165,6 @@ main (int argc, char **argv)
165 int result = STATE_UNKNOWN; 165 int result = STATE_UNKNOWN;
166 int disk_result = STATE_UNKNOWN; 166 int disk_result = STATE_UNKNOWN;
167 char *output; 167 char *output;
168 char *ko_output;
169 char *details; 168 char *details;
170 char *perf; 169 char *perf;
171 char *preamble; 170 char *preamble;
@@ -185,7 +184,6 @@ main (int argc, char **argv)
185 184
186 preamble = strdup (" - free space:"); 185 preamble = strdup (" - free space:");
187 output = strdup (""); 186 output = strdup ("");
188 ko_output = strdup ("");
189 details = strdup (""); 187 details = strdup ("");
190 perf = strdup (""); 188 perf = strdup ("");
191 stat_buf = malloc(sizeof *stat_buf); 189 stat_buf = malloc(sizeof *stat_buf);
@@ -350,6 +348,9 @@ main (int argc, char **argv)
350 TRUE, 0, 348 TRUE, 0,
351 TRUE, path->dtotal_units)); 349 TRUE, path->dtotal_units));
352 350
351 if (disk_result==STATE_OK && erronly && !verbose)
352 continue;
353
353 if(disk_result && verbose >= 1) { 354 if(disk_result && verbose >= 1) {
354 xasprintf(&flag_header, " %s [", state_text (disk_result)); 355 xasprintf(&flag_header, " %s [", state_text (disk_result));
355 } else { 356 } else {
@@ -375,27 +376,15 @@ main (int argc, char **argv)
375 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp); 376 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
376 */ 377 */
377 378
378 /* OS: #1420 save all not ok paths to different output, but only in case of error only option */
379 if (disk_result!=STATE_OK && erronly) {
380 xasprintf (&ko_output, "%s%s %s %.0f %s (%.0f%%",
381 ko_output, flag_header,
382 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
383 path->dfree_units,
384 units,
385 path->dfree_pct);
386 }
387
388 } 379 }
389 380
390 /* OS: #1420 only show offending paths if error only option is set, but show all paths if everything is ok */
391 output = (erronly && result!=STATE_OK) ? ko_output : output;
392 } 381 }
393 382
394 if (verbose >= 2) 383 if (verbose >= 2)
395 xasprintf (&output, "%s%s", output, details); 384 xasprintf (&output, "%s%s", output, details);
396 385
397 386
398 printf ("DISK %s%s%s|%s\n", state_text (result), preamble, output, perf); 387 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf);
399 return result; 388 return result;
400} 389}
401 390