1 /******************************************************************************
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 $Id$
19 *****************************************************************************/
21 const char *progname = "check_disk";
22 const char *program_name = "check_disk"; /* Required for coreutils libs */
23 const char *revision = "$Revision$";
24 const char *copyright = "1999-2005";
25 const char *email = "nagiosplug-devel@lists.sourceforge.net";
27 /*
28 * Additional inode code by Jorgen Lundman <lundman@lundman.net>
29 */
32 #include "common.h"
33 #if HAVE_INTTYPES_H
34 # include <inttypes.h>
35 #endif
36 #include <assert.h>
37 #include "popen.h"
38 #include "utils.h"
39 #include <stdarg.h>
40 #include "../lib/fsusage.h"
41 #include "../lib/mountlist.h"
42 #if HAVE_LIMITS_H
43 # include <limits.h>
44 #endif
46 /* If nonzero, show inode information. */
47 static int inode_format;
49 /* If nonzero, show even filesystems with zero size or
50 uninteresting types. */
51 static int show_all_fs = 1;
53 /* If nonzero, show only local filesystems. */
54 static int show_local_fs = 0;
56 /* If positive, the units to use when printing sizes;
57 if negative, the human-readable base. */
58 /* static int output_block_size; */
60 /* If nonzero, invoke the `sync' system call before getting any usage data.
61 Using this option can make df very slow, especially with many or very
62 busy disks. Note that this may make a difference on some systems --
63 SunOs4.1.3, for one. It is *not* necessary on Linux. */
64 /* static int require_sync = 0; */
66 /* A filesystem type to display. */
68 struct name_list
69 {
70 char *name;
71 int found;
72 int found_len;
73 uintmax_t w_df;
74 uintmax_t c_df;
75 double w_dfp;
76 double c_dfp;
77 double w_idfp;
78 double c_idfp;
79 struct name_list *name_next;
80 };
82 /* Linked list of filesystem types to display.
83 If `fs_select_list' is NULL, list all types.
84 This table is generated dynamically from command-line options,
85 rather than hardcoding into the program what it thinks are the
86 valid filesystem types; let the user specify any filesystem type
87 they want to, and if there are any filesystems of that type, they
88 will be shown.
90 Some filesystem types:
91 4.2 4.3 ufs nfs swap ignore io vm efs dbg */
93 /* static struct name_list *fs_select_list; */
95 /* Linked list of filesystem types to omit.
96 If the list is empty, don't exclude any types. */
98 static struct name_list *fs_exclude_list;
100 static struct name_list *dp_exclude_list;
102 static struct name_list *path_select_list;
104 static struct name_list *dev_select_list;
106 /* Linked list of mounted filesystems. */
107 static struct mount_entry *mount_list;
109 /* For long options that have no equivalent short option, use a
110 non-character as a pseudo short option, starting with CHAR_MAX + 1. */
111 enum
112 {
113 SYNC_OPTION = CHAR_MAX + 1,
114 NO_SYNC_OPTION,
115 BLOCK_SIZE_OPTION
116 };
118 #ifdef _AIX
119 #pragma alloca
120 #endif
122 int process_arguments (int, char **);
123 void print_path (const char *mypath);
124 int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, char *);
125 int check_disk (double usp, uintmax_t free_disk, double uisp);
126 int walk_name_list (struct name_list *list, const char *name);
127 void print_help (void);
128 void print_usage (void);
130 uintmax_t w_df = 0;
131 uintmax_t c_df = 0;
132 double w_dfp = -1.0;
133 double c_dfp = -1.0;
134 double w_idfp = -1.0;
135 double c_idfp = -1.0;
136 char *path;
137 char *exclude_device;
138 char *units;
139 uintmax_t mult = 1024 * 1024;
140 int verbose = 0;
141 int erronly = FALSE;
142 int display_mntp = FALSE;
144 /* Linked list of mounted filesystems. */
145 static struct mount_entry *mount_list;
149 int
150 main (int argc, char **argv)
151 {
152 double usp = -1.0, uisp = -1.0;
153 int result = STATE_UNKNOWN;
154 int disk_result = STATE_UNKNOWN;
155 char file_system[MAX_INPUT_BUFFER];
156 char *output;
157 char *details;
158 char *perf;
159 uintmax_t psize;
160 float free_space, free_space_pct, total_space, inode_space_pct;
162 struct mount_entry *me;
163 struct fs_usage fsp;
164 struct name_list *temp_list;
166 output = strdup (" - free space:");
167 details = strdup ("");
168 perf = strdup ("");
170 setlocale (LC_ALL, "");
171 bindtextdomain (PACKAGE, LOCALEDIR);
172 textdomain (PACKAGE);
174 mount_list = read_filesystem_list (0);
176 if (process_arguments (argc, argv) == ERROR)
177 usage4 (_("Could not parse arguments"));
179 /* if a list of paths has been selected, preseed the list with
180 * the longest matching filesystem name by iterating across
181 * the mountlist once ahead of time. this will allow a query on
182 * "/var/log" to return information about "/var" if no "/var/log"
183 * filesystem exists, etc. this is the default behavior already
184 * with df-based checks, but for systems with their own space
185 * checking routines, this should make them more consistent.
186 */
187 if(path_select_list){
188 for (me = mount_list; me; me = me->me_next) {
189 walk_name_list(path_select_list, me->me_mountdir);
190 walk_name_list(path_select_list, me->me_devname);
191 }
192 /* now pretend we never saw anything, but keep found_len.
193 * thus future searches will only match the best match */
194 for (temp_list = path_select_list; temp_list; temp_list=temp_list->name_next){
195 temp_list->found=0;
196 }
197 }
199 /* for every mount entry */
200 for (me = mount_list; me; me = me->me_next) {
201 /* if there's a list of paths to select, the current mount
202 * entry matches in path or device name, get fs usage */
203 if (path_select_list &&
204 (walk_name_list (path_select_list, me->me_mountdir) ||
205 walk_name_list (path_select_list, me->me_devname) ) ) {
206 get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
207 /* else if there's a list of paths/devices to select (but
208 * we didn't match above) skip to the next mount entry */
209 } else if (dev_select_list || path_select_list) {
210 continue;
211 /* skip remote filesystems if we're not interested in them */
212 } else if (me->me_remote && show_local_fs) {
213 continue;
214 /* skip pseudo fs's if we haven't asked for all fs's */
215 } else if (me->me_dummy && !show_all_fs) {
216 continue;
217 /* skip excluded fstypes */
218 } else if (fs_exclude_list && walk_name_list (fs_exclude_list, me->me_type)) {
219 continue;
220 /* skip excluded fs's */
221 } else if (dp_exclude_list &&
222 (walk_name_list (dp_exclude_list, me->me_devname) ||
223 walk_name_list (dp_exclude_list, me->me_mountdir))) {
224 continue;
225 /* otherwise, get fs usage */
226 } else {
227 get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
228 }
230 if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) {
231 usp = (double)(fsp.fsu_blocks - fsp.fsu_bavail) * 100 / fsp.fsu_blocks;
232 uisp = (double)(fsp.fsu_files - fsp.fsu_ffree) * 100 / fsp.fsu_files;
233 disk_result = check_disk (usp, fsp.fsu_bavail, uisp);
236 result = max_state (disk_result, result);
237 psize = fsp.fsu_blocks*fsp.fsu_blocksize/mult;
240 /* Moved this computation up here so we can add it
241 * to perf */
242 inode_space_pct = (float)fsp.fsu_ffree*100/fsp.fsu_files;
245 asprintf (&perf, "%s %s", perf,
246 perfdata ((!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
247 psize-(fsp.fsu_bavail*fsp.fsu_blocksize/mult), units,
248 TRUE, min ((uintmax_t)psize-(uintmax_t)w_df, (uintmax_t)((1.0-w_dfp/100.0)*psize)),
249 TRUE, min ((uintmax_t)psize-(uintmax_t)c_df, (uintmax_t)((1.0-c_dfp/100.0)*psize)),
250 TRUE, inode_space_pct,
252 TRUE, psize));
253 if (disk_result==STATE_OK && erronly && !verbose)
254 continue;
256 free_space = (float)fsp.fsu_bavail*fsp.fsu_blocksize/mult;
257 free_space_pct = (float)fsp.fsu_bavail*100/fsp.fsu_blocks;
258 total_space = (float)fsp.fsu_blocks*fsp.fsu_blocksize/mult;
259 if (disk_result!=STATE_OK || verbose>=0)
260 asprintf (&output, ("%s %s %.0f %s (%.0f%% inode=%.0f%%);"),
261 output,
262 (!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
263 free_space,
264 units,
265 free_space_pct,
266 inode_space_pct);
268 asprintf (&details, _("%s\n\
269 %.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
270 details, free_space, total_space, units, free_space_pct, inode_space_pct,
271 me->me_devname, me->me_type, me->me_mountdir,
272 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
274 }
276 }
278 if (verbose > 2)
279 asprintf (&output, "%s%s", output, details);
281 /* Override result if paths specified and not found */
282 temp_list = path_select_list;
283 while (temp_list) {
284 if (!temp_list->found) {
285 asprintf (&output, _("%s [%s not found]"), output, temp_list->name);
286 result = STATE_CRITICAL;
287 }
288 temp_list = temp_list->name_next;
289 }
291 printf ("DISK %s%s|%s\n", state_text (result), output, perf);
292 return result;
293 }
297 /* process command-line arguments */
298 int
299 process_arguments (int argc, char **argv)
300 {
301 int c;
302 struct name_list *se;
303 struct name_list **pathtail = &path_select_list;
304 struct name_list **fstail = &fs_exclude_list;
305 struct name_list **dptail = &dp_exclude_list;
306 struct name_list *temp_list;
307 int result = OK;
309 unsigned long l;
311 int option = 0;
312 static struct option longopts[] = {
313 {"timeout", required_argument, 0, 't'},
314 {"warning", required_argument, 0, 'w'},
315 {"critical", required_argument, 0, 'c'},
316 {"iwarning", required_argument, 0, 'W'},
317 /* Dang, -C is taken. We might want to reshuffle this. */
318 {"icritical", required_argument, 0, 'K'},
319 {"local", required_argument, 0, 'l'},
320 {"kilobytes", required_argument, 0, 'k'},
321 {"megabytes", required_argument, 0, 'm'},
322 {"units", required_argument, 0, 'u'},
323 {"path", required_argument, 0, 'p'},
324 {"partition", required_argument, 0, 'p'},
325 {"exclude_device", required_argument, 0, 'x'},
326 {"exclude-type", required_argument, 0, 'X'},
327 {"mountpoint", no_argument, 0, 'M'},
328 {"errors-only", no_argument, 0, 'e'},
329 {"verbose", no_argument, 0, 'v'},
330 {"quiet", no_argument, 0, 'q'},
331 {"clear", no_argument, 0, 'C'},
332 {"version", no_argument, 0, 'V'},
333 {"help", no_argument, 0, 'h'},
334 {0, 0, 0, 0}
335 };
337 if (argc < 2)
338 return ERROR;
340 se = (struct name_list *) malloc (sizeof (struct name_list));
341 se->name = strdup ("iso9660");
342 se->name_next = NULL;
343 se->found = 0;
344 se->found_len = 0;
345 *fstail = se;
346 fstail = &se->name_next;
348 for (c = 1; c < argc; c++)
349 if (strcmp ("-to", argv[c]) == 0)
350 strcpy (argv[c], "-t");
352 while (1) {
353 c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklM", longopts, &option);
355 if (c == -1 || c == EOF)
356 break;
358 switch (c) {
359 case 't': /* timeout period */
360 if (is_integer (optarg)) {
361 timeout_interval = atoi (optarg);
362 break;
363 }
364 else {
365 usage2 (_("Timeout interval must be a positive integer"), optarg);
366 }
367 case 'w': /* warning threshold */
368 if (is_intnonneg (optarg)) {
369 w_df = atoi (optarg);
370 break;
371 }
372 else if (strpbrk (optarg, ",:") &&
373 strstr (optarg, "%") &&
374 sscanf (optarg, "%lu%*[:,]%lf%%", &l, &w_dfp) == 2) {
375 w_df = (uintmax_t)l;
376 break;
377 }
378 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &w_dfp) == 1) {
379 break;
380 }
381 else {
382 usage4 (_("Warning threshold must be integer or percentage!"));
383 }
384 case 'c': /* critical threshold */
385 if (is_intnonneg (optarg)) {
386 c_df = atoi (optarg);
387 break;
388 }
389 else if (strpbrk (optarg, ",:") &&
390 strstr (optarg, "%") &&
391 sscanf (optarg, "%lu%*[,:]%lf%%", &l, &c_dfp) == 2) {
392 c_df = (uintmax_t)l;
393 break;
394 }
395 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &c_dfp) == 1) {
396 break;
397 }
398 else {
399 usage4 (_("Critical threshold must be integer or percentage!"));
400 }
403 case 'W': /* warning inode threshold */
404 if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &w_idfp) == 1) {
405 break;
406 }
407 else {
408 usage (_("Warning inode threshold must be percentage!\n"));
409 }
410 case 'K': /* kritical inode threshold */
411 if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &c_idfp) == 1) {
412 break;
413 }
414 else {
415 usage (_("Critical inode threshold must be percentage!\n"));
416 }
417 case 'u':
418 if (units)
419 free(units);
420 if (! strcmp (optarg, "bytes")) {
421 mult = (uintmax_t)1;
422 units = strdup ("B");
423 } else if (! strcmp (optarg, "kB")) {
424 mult = (uintmax_t)1024;
425 units = strdup ("kB");
426 } else if (! strcmp (optarg, "MB")) {
427 mult = (uintmax_t)1024 * 1024;
428 units = strdup ("MB");
429 } else if (! strcmp (optarg, "GB")) {
430 mult = (uintmax_t)1024 * 1024 * 1024;
431 units = strdup ("GB");
432 } else if (! strcmp (optarg, "TB")) {
433 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
434 units = strdup ("TB");
435 } else {
436 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
437 }
438 if (units == NULL)
439 die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
440 break;
441 case 'k': /* display mountpoint */
442 mult = 1024;
443 if (units)
444 free(units);
445 units = strdup ("kB");
446 break;
447 case 'm': /* display mountpoint */
448 mult = 1024 * 1024;
449 if (units)
450 free(units);
451 units = strdup ("MB");
452 break;
453 case 'l':
454 show_local_fs = 1;
455 break;
456 case 'p': /* select path */
457 se = (struct name_list *) malloc (sizeof (struct name_list));
458 se->name = optarg;
459 se->name_next = NULL;
460 se->w_df = w_df;
461 se->c_df = c_df;
462 se->w_dfp = w_dfp;
463 se->c_dfp = c_dfp;
464 se->found = 0;
465 se->found_len = 0;
466 *pathtail = se;
467 pathtail = &se->name_next;
468 break;
469 case 'x': /* exclude path or partition */
470 se = (struct name_list *) malloc (sizeof (struct name_list));
471 se->name = optarg;
472 se->name_next = NULL;
474 /* If you don't clear the w_fd etc values here, they
475 * get processed when you walk the list and assigned
476 * to the global w_df!
477 */
478 se->w_df = 0;
479 se->c_df = 0;
480 se->w_dfp = 0;
481 se->c_dfp = 0;
482 se->found = 0;
483 se->found_len = 0;
484 *dptail = se;
485 dptail = &se->name_next;
486 break;
487 case 'X': /* exclude file system type */
488 se = (struct name_list *) malloc (sizeof (struct name_list));
489 se->name = optarg;
490 se->name_next = NULL;
491 /* If you don't clear the w_fd etc values here, they
492 * get processed when you walk the list and assigned
493 * to the global w_df!
494 */
495 se->w_df = 0;
496 se->c_df = 0;
497 se->w_dfp = 0;
498 se->c_dfp = 0;
499 se->found = 0;
500 se->found_len = 0;
501 *fstail = se;
502 fstail = &se->name_next;
503 break;
504 case 'v': /* verbose */
505 verbose++;
506 break;
507 case 'q': /* verbose */
508 verbose--;
509 break;
510 case 'e':
511 erronly = TRUE;
512 break;
513 case 'M': /* display mountpoint */
514 display_mntp = TRUE;
515 break;
516 case 'C':
517 w_df = 0;
518 c_df = 0;
519 w_dfp = -1.0;
520 c_dfp = -1.0;
521 break;
522 case 'V': /* version */
523 print_revision (progname, revision);
524 exit (STATE_OK);
525 case 'h': /* help */
526 print_help ();
527 exit (STATE_OK);
528 case '?': /* help */
529 usage (_("Unknown argument"));
530 }
531 }
533 /* Support for "check_disk warn crit [fs]" with thresholds at used level */
534 c = optind;
535 if (w_dfp < 0 && argc > c && is_intnonneg (argv[c]))
536 w_dfp = (100.0 - atof (argv[c++]));
538 if (c_dfp < 0 && argc > c && is_intnonneg (argv[c]))
539 c_dfp = (100.0 - atof (argv[c++]));
541 if (argc > c && path == NULL) {
542 se = (struct name_list *) malloc (sizeof (struct name_list));
543 se->name = strdup (argv[c++]);
544 se->name_next = NULL;
545 se->w_df = w_df;
546 se->c_df = c_df;
547 se->w_dfp = w_dfp;
548 se->c_dfp = c_dfp;
549 se->found =0;
550 se->found_len = 0;
551 *pathtail = se;
552 }
554 if (path_select_list) {
555 temp_list = path_select_list;
556 while (temp_list) {
557 if (validate_arguments (temp_list->w_df,
558 temp_list->c_df,
559 temp_list->w_dfp,
560 temp_list->c_dfp,
561 temp_list->w_idfp,
562 temp_list->c_idfp,
563 temp_list->name) == ERROR)
564 result = ERROR;
565 temp_list = temp_list->name_next;
566 }
567 return result;
568 } else {
569 return validate_arguments (w_df, c_df, w_dfp, c_dfp, w_idfp, c_idfp, NULL);
570 }
571 }
575 void
576 print_path (const char *mypath)
577 {
578 if (mypath == NULL)
579 printf ("\n");
580 else
581 printf (_(" for %s\n"), mypath);
583 return;
584 }
588 int
589 validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, double iwp, double icp, char *mypath)
590 {
591 if (w < 0 && c < 0 && wp < 0.0 && cp < 0.0) {
592 printf (_("INPUT ERROR: No thresholds specified"));
593 print_path (mypath);
594 return ERROR;
595 }
596 else if ((wp >= 0.0 || cp >= 0.0) &&
597 (wp < 0.0 || cp < 0.0 || wp > 100.0 || cp > 100.0 || cp > wp)) {
598 printf (_("\
599 INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
600 cp, wp);
601 print_path (mypath);
602 return ERROR;
603 }
604 else if ((iwp >= 0.0 || icp >= 0.0) &&
605 (iwp < 0.0 || icp < 0.0 || iwp > 100.0 || icp > 100.0 || icp > iwp)) {
606 printf (_("\
607 INPUT ERROR: C_IDFP (%f) should be less than W_IDFP (%.1f) and both should be between zero and 100 percent, inclusive"),
608 icp, iwp);
609 print_path (mypath);
610 return ERROR;
611 }
612 else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) {
613 printf (_("\
614 INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
615 (unsigned long)c, (unsigned long)w);
616 print_path (mypath);
617 return ERROR;
618 }
620 if (units == NULL) {
621 units = strdup ("MB");
622 mult = (uintmax_t)1024 * 1024;
623 }
624 return OK;
625 }
629 int
631 check_disk (double usp, uintmax_t free_disk, double uisp)
632 {
633 int result = STATE_UNKNOWN;
634 /* check the percent used space against thresholds */
635 if (usp >= 0.0 && c_dfp >=0.0 && usp >= (100.0 - c_dfp))
636 result = STATE_CRITICAL;
637 else if (uisp >= 0.0 && c_idfp >=0.0 && uisp >= (100.0 - c_idfp))
638 result = STATE_CRITICAL;
639 else if (c_df > 0 && free_disk <= c_df)
640 result = STATE_CRITICAL;
641 else if (usp >= 0.0 && w_dfp >=0.0 && usp >= (100.0 - w_dfp))
642 result = STATE_WARNING;
643 else if (uisp >= 0.0 && w_idfp >=0.0 && uisp >= (100.0 - w_idfp))
644 result = STATE_WARNING;
645 else if (w_df > 0 && free_disk <= w_df)
646 result = STATE_WARNING;
647 else if (usp >= 0.0)
648 result = STATE_OK;
649 return result;
650 }
654 int
655 walk_name_list (struct name_list *list, const char *name)
656 {
657 int name_len;
658 name_len = strlen(name);
659 while (list) {
660 /* if the paths match up to the length of the mount path,
661 * AND if the mount path name is longer than the longest
662 * found match, we have a new winner */
663 if (name_len >= list->found_len &&
664 ! strncmp(list->name, name, name_len)) {
665 list->found = 1;
666 list->found_len = name_len;
667 /* if required for name_lists that have not saved w_df, etc (eg exclude lists) */
668 if (list->w_df) w_df = list->w_df;
669 if (list->c_df) c_df = list->c_df;
670 if (list->w_dfp>=0.0) w_dfp = list->w_dfp;
671 if (list->c_dfp>=0.0) c_dfp = list->c_dfp;
672 return TRUE;
673 }
674 list = list->name_next;
675 }
676 return FALSE;
677 }
681 void
682 print_help (void)
683 {
684 print_revision (progname, revision);
686 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
687 printf (COPYRIGHT, copyright, email);
689 printf (_("This plugin checks the amount of used disk space on a mounted file system"));
690 printf (_("and generates an alert if free space is less than one of the threshold values"));
692 printf ("\n\n");
694 print_usage ();
696 printf (_(UT_HELP_VRSN));
698 printf (" %s\n", "-w, --warning=INTEGER");
699 printf (" %s\n", _("Exit with WARNING status if less than INTEGER units of disk are free"));
700 printf (" %s\n", "-w, --warning=PERCENT%");
701 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of disk space is free"));
702 printf (" %s\n", "-W, --iwarning=PERCENT%");
703 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of inode space is free"));
704 printf (" %s\n", "-K, --icritical=PERCENT%");
705 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free"));
706 printf (" %s\n", "-c, --critical=INTEGER");
707 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER units of disk are free"));
708 printf (" %s\n", "-c, --critical=PERCENT%");
709 printf (" %s\n", _("Exit with CRITCAL status if less than PERCENT of disk space is free"));
710 printf (" %s\n", "-C, --clear");
711 printf (" %s\n", _("Clear thresholds"));
712 printf (" %s\n", "-u, --units=STRING");
713 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
714 printf (" %s\n", "-k, --kilobytes");
715 printf (" %s\n", _("Same as '--units kB'"));
716 printf (" %s\n", "-m, --megabytes");
717 printf (" %s\n", _("Same as '--units MB'"));
718 printf (" %s\n", "-l, --local");
719 printf (" %s\n", _("Only check local filesystems"));
720 printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
721 printf (" %s\n", _("Path or partition (may be repeated)"));
722 printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
723 printf (" %s\n", _("Ignore device (only works if -p unspecified)"));
724 printf (" %s\n", _("-X, --exclude-type=TYPE <STRING>"));
725 printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
726 printf (" %s\n", "-m, --mountpoint");
727 printf (" %s\n", _("Display the mountpoint instead of the partition"));
728 printf (" %s\n", "-e, --errors-only");
729 printf (" %s\n", _("Display only devices/mountpoints with errors"));
730 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
731 printf (_(UT_VERBOSE));
732 printf ("\n");
733 printf ("%s\n", _("Examples:"));
734 printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /");
735 printf (" %s\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"));
736 printf (_(UT_SUPPORT));
737 }
741 void
742 print_usage (void)
743 {
744 printf (_("Usage:"));
745 printf (" %s -w limit -c limit [-p path | -x device] [-t timeout]", progname);
746 printf ("[-m] [-e] [-W limit] [-K limit] [-v] [-q]\n");
747 }