summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 14234483..6beaf861 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -45,6 +45,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
45#include <assert.h> 45#include <assert.h>
46#include "popen.h" 46#include "popen.h"
47#include "utils.h" 47#include "utils.h"
48#include "utils_disk.h"
48#include <stdarg.h> 49#include <stdarg.h>
49#include "fsusage.h" 50#include "fsusage.h"
50#include "mountlist.h" 51#include "mountlist.h"
@@ -52,7 +53,6 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
52# include <limits.h> 53# include <limits.h>
53#endif 54#endif
54 55
55#include "utils_disk.h"
56 56
57/* If nonzero, show inode information. */ 57/* If nonzero, show inode information. */
58static int inode_format; 58static int inode_format;
@@ -94,7 +94,7 @@ static struct name_list *fs_exclude_list;
94 94
95static struct name_list *dp_exclude_list; 95static struct name_list *dp_exclude_list;
96 96
97static struct parameter_list *path_select_list; 97static struct parameter_list *path_select_list = NULL;
98 98
99/* Linked list of mounted filesystems. */ 99/* Linked list of mounted filesystems. */
100static struct mount_entry *mount_list; 100static struct mount_entry *mount_list;
@@ -296,12 +296,17 @@ process_arguments (int argc, char **argv)
296{ 296{
297 int c; 297 int c;
298 struct parameter_list *se; 298 struct parameter_list *se;
299 struct parameter_list **pathtail = &path_select_list;
300 struct parameter_list *temp_list; 299 struct parameter_list *temp_list;
301 int result = OK; 300 int result = OK;
302 struct stat *stat_buf; 301 struct stat *stat_buf;
302 char *warn_freespace = NULL;
303 char *crit_freespace = NULL;
304 char *warn_freespace_percent = NULL;
305 char *crit_freespace_percent = NULL;
306 char temp_string[MAX_INPUT_BUFFER];
303 307
304 unsigned long l; 308 unsigned long l;
309 double f;
305 310
306 int option = 0; 311 int option = 0;
307 static struct option longopts[] = { 312 static struct option longopts[] = {
@@ -355,6 +360,15 @@ process_arguments (int argc, char **argv)
355 usage2 (_("Timeout interval must be a positive integer"), optarg); 360 usage2 (_("Timeout interval must be a positive integer"), optarg);
356 } 361 }
357 case 'w': /* warning threshold */ 362 case 'w': /* warning threshold */
363 /*
364 if (strstr(optarg, "%")) {
365 printf("Got percent with optarg=%s\n", optarg);
366 warn_freespace_percent = optarg;
367 } else {
368 warn_freespace = optarg;
369 }
370 break;
371 */
358 if (is_intnonneg (optarg)) { 372 if (is_intnonneg (optarg)) {
359 w_df = atoi (optarg); 373 w_df = atoi (optarg);
360 break; 374 break;
@@ -444,19 +458,13 @@ process_arguments (int argc, char **argv)
444 show_local_fs = 1; 458 show_local_fs = 1;
445 break; 459 break;
446 case 'p': /* select path */ 460 case 'p': /* select path */
447 se = (struct parameter_list *) malloc (sizeof (struct parameter_list)); 461 se = np_add_parameter(&path_select_list, optarg);
448 se->name = optarg;
449 se->name_next = NULL;
450 se->w_df = w_df; 462 se->w_df = w_df;
451 se->c_df = c_df; 463 se->c_df = c_df;
452 se->w_dfp = w_dfp; 464 se->w_dfp = w_dfp;
453 se->c_dfp = c_dfp; 465 se->c_dfp = c_dfp;
454 se->w_idfp = w_idfp; 466 se->w_idfp = w_idfp;
455 se->c_idfp = c_idfp; 467 se->c_idfp = c_idfp;
456 se->found = 0;
457 se->found_len = 0;
458 *pathtail = se;
459 pathtail = &se->name_next;
460 break; 468 break;
461 case 'x': /* exclude path or partition */ 469 case 'x': /* exclude path or partition */
462 np_add_name(&dp_exclude_list, optarg); 470 np_add_name(&dp_exclude_list, optarg);
@@ -507,18 +515,13 @@ process_arguments (int argc, char **argv)
507 c_dfp = (100.0 - atof (argv[c++])); 515 c_dfp = (100.0 - atof (argv[c++]));
508 516
509 if (argc > c && path == NULL) { 517 if (argc > c && path == NULL) {
510 se = (struct parameter_list *) malloc (sizeof (struct parameter_list)); 518 se = np_add_parameter(&path_select_list, strdup(argv[c++]));
511 se->name = strdup (argv[c++]);
512 se->name_next = NULL;
513 se->w_df = w_df; 519 se->w_df = w_df;
514 se->c_df = c_df; 520 se->c_df = c_df;
515 se->w_dfp = w_dfp; 521 se->w_dfp = w_dfp;
516 se->c_dfp = c_dfp; 522 se->c_dfp = c_dfp;
517 se->w_idfp = w_idfp; 523 se->w_idfp = w_idfp;
518 se->c_idfp = c_idfp; 524 se->c_idfp = c_idfp;
519 se->found =0;
520 se->found_len = 0;
521 *pathtail = se;
522 } 525 }
523 526
524 if (path_select_list) { 527 if (path_select_list) {
@@ -604,7 +607,6 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
604 607
605 608
606int 609int
607
608check_disk (double usp, uintmax_t free_disk, double uisp) 610check_disk (double usp, uintmax_t free_disk, double uisp)
609{ 611{
610 int result = STATE_UNKNOWN; 612 int result = STATE_UNKNOWN;