summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_disk.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7bed4d4..f696672 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -194,16 +194,11 @@ main (int argc, char **argv)
194 units, 194 units,
195 free_space_pct, 195 free_space_pct,
196 (!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir); 196 (!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
197 asprintf (&details, _("%s\n%.0f of %.0f %s (%.0f%%) free on %s (type %s mounted on %s) warn:%d crit:%d warn%%:%.0f%% crit%%:%.0f%%"), 197 asprintf (&details, _("%s\n\
198 details, 198%.0f of %.0f %s (%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
199 free_space, 199 details, free_space, total_space, units, free_space_pct,
200 total_space, 200 me->me_devname, me->me_type, me->me_mountdir,
201 units, 201 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
202 free_space_pct,
203 me->me_devname,
204 me->me_type,
205 me->me_mountdir,
206 w_df, c_df, w_dfp, c_dfp);
207 } 202 }
208 203
209 } 204 }
@@ -238,6 +233,7 @@ process_arguments (int argc, char **argv)
238 struct name_list **fstail = &fs_exclude_list; 233 struct name_list **fstail = &fs_exclude_list;
239 struct name_list **dptail = &dp_exclude_list; 234 struct name_list **dptail = &dp_exclude_list;
240 struct name_list *temp_list; 235 struct name_list *temp_list;
236 unsigned long l;
241 int result = OK; 237 int result = OK;
242 238
243 int option_index = 0; 239 int option_index = 0;
@@ -298,7 +294,8 @@ process_arguments (int argc, char **argv)
298 } 294 }
299 else if (strpbrk (optarg, ",:") && 295 else if (strpbrk (optarg, ",:") &&
300 strstr (optarg, "%") && 296 strstr (optarg, "%") &&
301 sscanf (optarg, "%ul%*[:,]%lf%%", &w_df, &w_dfp) == 2) { 297 sscanf (optarg, "%lu%*[:,]%lf%%", &l, &w_dfp) == 2) {
298 w_df = (uintmax_t)l;
302 break; 299 break;
303 } 300 }
304 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &w_dfp) == 1) { 301 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &w_dfp) == 1) {
@@ -314,7 +311,8 @@ process_arguments (int argc, char **argv)
314 } 311 }
315 else if (strpbrk (optarg, ",:") && 312 else if (strpbrk (optarg, ",:") &&
316 strstr (optarg, "%") && 313 strstr (optarg, "%") &&
317 sscanf (optarg, "%ul%*[,:]%lf%%", &c_df, &c_dfp) == 2) { 314 sscanf (optarg, "%lu%*[,:]%lf%%", &l, &c_dfp) == 2) {
315 c_df = (uintmax_t)l;
318 break; 316 break;
319 } 317 }
320 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &c_dfp) == 1) { 318 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &c_dfp) == 1) {
@@ -326,30 +324,30 @@ process_arguments (int argc, char **argv)
326 case 'u': 324 case 'u':
327 if (! strcmp (optarg, "bytes")) { 325 if (! strcmp (optarg, "bytes")) {
328 mult = (uintmax_t)1; 326 mult = (uintmax_t)1;
329 units = "B"; 327 units = strdup ("B");
330 } else if (! strcmp (optarg, "kB")) { 328 } else if (! strcmp (optarg, "kB")) {
331 mult = (uintmax_t)1024; 329 mult = (uintmax_t)1024;
332 units = "kB"; 330 units = strdup ("kB");
333 } else if (! strcmp (optarg, "MB")) { 331 } else if (! strcmp (optarg, "MB")) {
334 mult = (uintmax_t)1024 * 1024; 332 mult = (uintmax_t)1024 * 1024;
335 units = "MB"; 333 units = strdup ("MB");
336 } else if (! strcmp (optarg, "GB")) { 334 } else if (! strcmp (optarg, "GB")) {
337 mult = (uintmax_t)1024 * 1024 * 1024; 335 mult = (uintmax_t)1024 * 1024 * 1024;
338 units = "GB"; 336 units = strdup ("GB");
339 } else if (! strcmp (optarg, "TB")) { 337 } else if (! strcmp (optarg, "TB")) {
340 mult = (uintmax_t)1024 * 1024 * 1024 * 1024; 338 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
341 units = "TB"; 339 units = strdup ("TB");
342 } else { 340 } else {
343 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 341 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
344 } 342 }
345 break; 343 break;
346 case 'k': /* display mountpoint */ 344 case 'k': /* display mountpoint */
347 mult = 1024; 345 mult = 1024;
348 units = "kB"; 346 units = strdup ("kB");
349 break; 347 break;
350 case 'm': /* display mountpoint */ 348 case 'm': /* display mountpoint */
351 mult = 1024 * 1024; 349 mult = 1024 * 1024;
352 units = "MB"; 350 units = strdup ("kB");
353 break; 351 break;
354 case 'l': 352 case 'l':
355 show_local_fs = 1; 353 show_local_fs = 1;
@@ -476,9 +474,10 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
476 print_path (path); 474 print_path (path);
477 return ERROR; 475 return ERROR;
478 } 476 }
479 else { 477
480 return OK; 478 if (units == NULL)
481 } 479 units = strdup ("MB");
480 return OK;
482} 481}
483 482
484 483