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.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f696672..bd06021 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -233,9 +233,10 @@ process_arguments (int argc, char **argv)
233 struct name_list **fstail = &fs_exclude_list; 233 struct name_list **fstail = &fs_exclude_list;
234 struct name_list **dptail = &dp_exclude_list; 234 struct name_list **dptail = &dp_exclude_list;
235 struct name_list *temp_list; 235 struct name_list *temp_list;
236 unsigned long l;
237 int result = OK; 236 int result = OK;
238 237
238 unsigned long l;
239
239 int option_index = 0; 240 int option_index = 0;
240 static struct option long_options[] = { 241 static struct option long_options[] = {
241 {"timeout", required_argument, 0, 't'}, 242 {"timeout", required_argument, 0, 't'},
@@ -322,6 +323,8 @@ process_arguments (int argc, char **argv)
322 usage (_("Critical threshold must be integer or percentage!\n")); 323 usage (_("Critical threshold must be integer or percentage!\n"));
323 } 324 }
324 case 'u': 325 case 'u':
326 if (units)
327 free(units);
325 if (! strcmp (optarg, "bytes")) { 328 if (! strcmp (optarg, "bytes")) {
326 mult = (uintmax_t)1; 329 mult = (uintmax_t)1;
327 units = strdup ("B"); 330 units = strdup ("B");
@@ -340,13 +343,19 @@ process_arguments (int argc, char **argv)
340 } else { 343 } else {
341 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 344 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
342 } 345 }
346 if (units == NULL)
347 die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
343 break; 348 break;
344 case 'k': /* display mountpoint */ 349 case 'k': /* display mountpoint */
345 mult = 1024; 350 mult = 1024;
351 if (units)
352 free(units);
346 units = strdup ("kB"); 353 units = strdup ("kB");
347 break; 354 break;
348 case 'm': /* display mountpoint */ 355 case 'm': /* display mountpoint */
349 mult = 1024 * 1024; 356 mult = 1024 * 1024;
357 if (units)
358 free(units);
350 units = strdup ("kB"); 359 units = strdup ("kB");
351 break; 360 break;
352 case 'l': 361 case 'l':
@@ -475,8 +484,10 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
475 return ERROR; 484 return ERROR;
476 } 485 }
477 486
478 if (units == NULL) 487 if (units == NULL) {
479 units = strdup ("MB"); 488 units = strdup ("MB");
489 mult = (uintmax_t)1024 * 1024;
490 }
480 return OK; 491 return OK;
481} 492}
482 493