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 asprintf (&output, "%s|%s", output, perf);
280 if (verbose > 2)
281 asprintf (&output, "%s%s", output, details);
283 /* Override result if paths specified and not found */
284 temp_list = path_select_list;
285 while (temp_list) {
286 if (!temp_list->found) {
287 asprintf (&output, _("%s [%s not found]"), output, temp_list->name);
288 result = STATE_CRITICAL;
289 }
290 temp_list = temp_list->name_next;
291 }
293 printf ("DISK %s%s\n", state_text (result), output);
294 return result;
295 }
299 /* process command-line arguments */
300 int
301 process_arguments (int argc, char **argv)
302 {
303 int c;
304 struct name_list *se;
305 struct name_list **pathtail = &path_select_list;
306 struct name_list **fstail = &fs_exclude_list;
307 struct name_list **dptail = &dp_exclude_list;
308 struct name_list *temp_list;
309 int result = OK;
311 unsigned long l;
313 int option = 0;
314 static struct option longopts[] = {
315 {"timeout", required_argument, 0, 't'},
316 {"warning", required_argument, 0, 'w'},
317 {"critical", required_argument, 0, 'c'},
318 {"iwarning", required_argument, 0, 'W'},
319 /* Dang, -C is taken. We might want to reshuffle this. */
320 {"icritical", required_argument, 0, 'K'},
321 {"local", required_argument, 0, 'l'},
322 {"kilobytes", required_argument, 0, 'k'},
323 {"megabytes", required_argument, 0, 'm'},
324 {"units", required_argument, 0, 'u'},
325 {"path", required_argument, 0, 'p'},
326 {"partition", required_argument, 0, 'p'},
327 {"exclude_device", required_argument, 0, 'x'},
328 {"exclude-type", required_argument, 0, 'X'},
329 {"mountpoint", no_argument, 0, 'M'},
330 {"errors-only", no_argument, 0, 'e'},
331 {"verbose", no_argument, 0, 'v'},
332 {"quiet", no_argument, 0, 'q'},
333 {"clear", no_argument, 0, 'C'},
334 {"version", no_argument, 0, 'V'},
335 {"help", no_argument, 0, 'h'},
336 {0, 0, 0, 0}
337 };
339 if (argc < 2)
340 return ERROR;
342 se = (struct name_list *) malloc (sizeof (struct name_list));
343 se->name = strdup ("iso9660");
344 se->name_next = NULL;
345 se->found = 0;
346 se->found_len = 0;
347 *fstail = se;
348 fstail = &se->name_next;
350 for (c = 1; c < argc; c++)
351 if (strcmp ("-to", argv[c]) == 0)
352 strcpy (argv[c], "-t");
354 while (1) {
355 c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklM", longopts, &option);
357 if (c == -1 || c == EOF)
358 break;
360 switch (c) {
361 case 't': /* timeout period */
362 if (is_integer (optarg)) {
363 timeout_interval = atoi (optarg);
364 break;
365 }
366 else {
367 usage2 (_("Timeout interval must be a positive integer"), optarg);
368 }
369 case 'w': /* warning threshold */
370 if (is_intnonneg (optarg)) {
371 w_df = atoi (optarg);
372 break;
373 }
374 else if (strpbrk (optarg, ",:") &&
375 strstr (optarg, "%") &&
376 sscanf (optarg, "%lu%*[:,]%lf%%", &l, &w_dfp) == 2) {
377 w_df = (uintmax_t)l;
378 break;
379 }
380 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &w_dfp) == 1) {
381 break;
382 }
383 else {
384 usage4 (_("Warning threshold must be integer or percentage!"));
385 }
386 case 'c': /* critical threshold */
387 if (is_intnonneg (optarg)) {
388 c_df = atoi (optarg);
389 break;
390 }
391 else if (strpbrk (optarg, ",:") &&
392 strstr (optarg, "%") &&
393 sscanf (optarg, "%lu%*[,:]%lf%%", &l, &c_dfp) == 2) {
394 c_df = (uintmax_t)l;
395 break;
396 }
397 else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &c_dfp) == 1) {
398 break;
399 }
400 else {
401 usage4 (_("Critical threshold must be integer or percentage!"));
402 }
405 case 'W': /* warning inode threshold */
406 if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &w_idfp) == 1) {
407 break;
408 }
409 else {
410 usage (_("Warning inode threshold must be percentage!\n"));
411 }
412 case 'K': /* kritical inode threshold */
413 if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &c_idfp) == 1) {
414 break;
415 }
416 else {
417 usage (_("Critical inode threshold must be percentage!\n"));
418 }
419 case 'u':
420 if (units)
421 free(units);
422 if (! strcmp (optarg, "bytes")) {
423 mult = (uintmax_t)1;
424 units = strdup ("B");
425 } else if (! strcmp (optarg, "kB")) {
426 mult = (uintmax_t)1024;
427 units = strdup ("kB");
428 } else if (! strcmp (optarg, "MB")) {
429 mult = (uintmax_t)1024 * 1024;
430 units = strdup ("MB");
431 } else if (! strcmp (optarg, "GB")) {
432 mult = (uintmax_t)1024 * 1024 * 1024;
433 units = strdup ("GB");
434 } else if (! strcmp (optarg, "TB")) {
435 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
436 units = strdup ("TB");
437 } else {
438 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
439 }
440 if (units == NULL)
441 die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
442 break;
443 case 'k': /* display mountpoint */
444 mult = 1024;
445 if (units)
446 free(units);
447 units = strdup ("kB");
448 break;
449 case 'm': /* display mountpoint */
450 mult = 1024 * 1024;
451 if (units)
452 free(units);
453 units = strdup ("MB");
454 break;
455 case 'l':
456 show_local_fs = 1;
457 break;
458 case 'p': /* select path */
459 se = (struct name_list *) malloc (sizeof (struct name_list));
460 se->name = optarg;
461 se->name_next = NULL;
462 se->w_df = w_df;
463 se->c_df = c_df;
464 se->w_dfp = w_dfp;
465 se->c_dfp = c_dfp;
466 se->found = 0;
467 se->found_len = 0;
468 *pathtail = se;
469 pathtail = &se->name_next;
470 break;
471 case 'x': /* exclude path or partition */
472 se = (struct name_list *) malloc (sizeof (struct name_list));
473 se->name = optarg;
474 se->name_next = NULL;
476 /* If you don't clear the w_fd etc values here, they
477 * get processed when you walk the list and assigned
478 * to the global w_df!
479 */
480 se->w_df = 0;
481 se->c_df = 0;
482 se->w_dfp = 0;
483 se->c_dfp = 0;
484 se->found = 0;
485 se->found_len = 0;
486 *dptail = se;
487 dptail = &se->name_next;
488 break;
489 case 'X': /* exclude file system type */
490 se = (struct name_list *) malloc (sizeof (struct name_list));
491 se->name = optarg;
492 se->name_next = NULL;
493 /* If you don't clear the w_fd etc values here, they
494 * get processed when you walk the list and assigned
495 * to the global w_df!
496 */
497 se->w_df = 0;
498 se->c_df = 0;
499 se->w_dfp = 0;
500 se->c_dfp = 0;
501 se->found = 0;
502 se->found_len = 0;
503 *fstail = se;
504 fstail = &se->name_next;
505 break;
506 case 'v': /* verbose */
507 verbose++;
508 break;
509 case 'q': /* verbose */
510 verbose--;
511 break;
512 case 'e':
513 erronly = TRUE;
514 break;
515 case 'M': /* display mountpoint */
516 display_mntp = TRUE;
517 break;
518 case 'C':
519 w_df = 0;
520 c_df = 0;
521 w_dfp = -1.0;
522 c_dfp = -1.0;
523 break;
524 case 'V': /* version */
525 print_revision (progname, revision);
526 exit (STATE_OK);
527 case 'h': /* help */
528 print_help ();
529 exit (STATE_OK);
530 case '?': /* help */
531 usage (_("Unknown argument"));
532 }
533 }
535 /* Support for "check_disk warn crit [fs]" with thresholds at used level */
536 c = optind;
537 if (w_dfp < 0 && argc > c && is_intnonneg (argv[c]))
538 w_dfp = (100.0 - atof (argv[c++]));
540 if (c_dfp < 0 && argc > c && is_intnonneg (argv[c]))
541 c_dfp = (100.0 - atof (argv[c++]));
543 if (argc > c && path == NULL) {
544 se = (struct name_list *) malloc (sizeof (struct name_list));
545 se->name = strdup (argv[c++]);
546 se->name_next = NULL;
547 se->w_df = w_df;
548 se->c_df = c_df;
549 se->w_dfp = w_dfp;
550 se->c_dfp = c_dfp;
551 se->found =0;
552 se->found_len = 0;
553 *pathtail = se;
554 }
556 if (path_select_list) {
557 temp_list = path_select_list;
558 while (temp_list) {
559 if (validate_arguments (temp_list->w_df,
560 temp_list->c_df,
561 temp_list->w_dfp,
562 temp_list->c_dfp,
563 temp_list->w_idfp,
564 temp_list->c_idfp,
565 temp_list->name) == ERROR)
566 result = ERROR;
567 temp_list = temp_list->name_next;
568 }
569 return result;
570 } else {
571 return validate_arguments (w_df, c_df, w_dfp, c_dfp, w_idfp, c_idfp, NULL);
572 }
573 }
577 void
578 print_path (const char *mypath)
579 {
580 if (mypath == NULL)
581 printf ("\n");
582 else
583 printf (_(" for %s\n"), mypath);
585 return;
586 }
590 int
591 validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, double iwp, double icp, char *mypath)
592 {
593 if (w < 0 && c < 0 && wp < 0.0 && cp < 0.0) {
594 printf (_("INPUT ERROR: No thresholds specified"));
595 print_path (mypath);
596 return ERROR;
597 }
598 else if ((wp >= 0.0 || cp >= 0.0) &&
599 (wp < 0.0 || cp < 0.0 || wp > 100.0 || cp > 100.0 || cp > wp)) {
600 printf (_("\
601 INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
602 cp, wp);
603 print_path (mypath);
604 return ERROR;
605 }
606 else if ((iwp >= 0.0 || icp >= 0.0) &&
607 (iwp < 0.0 || icp < 0.0 || iwp > 100.0 || icp > 100.0 || icp > iwp)) {
608 printf (_("\
609 INPUT ERROR: C_IDFP (%f) should be less than W_IDFP (%.1f) and both should be between zero and 100 percent, inclusive"),
610 icp, iwp);
611 print_path (mypath);
612 return ERROR;
613 }
614 else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) {
615 printf (_("\
616 INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
617 (unsigned long)c, (unsigned long)w);
618 print_path (mypath);
619 return ERROR;
620 }
622 if (units == NULL) {
623 units = strdup ("MB");
624 mult = (uintmax_t)1024 * 1024;
625 }
626 return OK;
627 }
631 int
633 check_disk (double usp, uintmax_t free_disk, double uisp)
634 {
635 int result = STATE_UNKNOWN;
636 /* check the percent used space against thresholds */
637 if (usp >= 0.0 && c_dfp >=0.0 && usp >= (100.0 - c_dfp))
638 result = STATE_CRITICAL;
639 else if (uisp >= 0.0 && c_idfp >=0.0 && uisp >= (100.0 - c_idfp))
640 result = STATE_CRITICAL;
641 else if (c_df > 0 && free_disk <= c_df)
642 result = STATE_CRITICAL;
643 else if (usp >= 0.0 && w_dfp >=0.0 && usp >= (100.0 - w_dfp))
644 result = STATE_WARNING;
645 else if (uisp >= 0.0 && w_idfp >=0.0 && uisp >= (100.0 - w_idfp))
646 result = STATE_WARNING;
647 else if (w_df > 0 && free_disk <= w_df)
648 result = STATE_WARNING;
649 else if (usp >= 0.0)
650 result = STATE_OK;
651 return result;
652 }
656 int
657 walk_name_list (struct name_list *list, const char *name)
658 {
659 int name_len;
660 name_len = strlen(name);
661 while (list) {
662 /* if the paths match up to the length of the mount path,
663 * AND if the mount path name is longer than the longest
664 * found match, we have a new winner */
665 if (name_len >= list->found_len &&
666 ! strncmp(list->name, name, name_len)) {
667 list->found = 1;
668 list->found_len = name_len;
669 /* if required for name_lists that have not saved w_df, etc (eg exclude lists) */
670 if (list->w_df) w_df = list->w_df;
671 if (list->c_df) c_df = list->c_df;
672 if (list->w_dfp>=0.0) w_dfp = list->w_dfp;
673 if (list->c_dfp>=0.0) c_dfp = list->c_dfp;
674 return TRUE;
675 }
676 list = list->name_next;
677 }
678 return FALSE;
679 }
683 void
684 print_help (void)
685 {
686 print_revision (progname, revision);
688 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
689 printf (COPYRIGHT, copyright, email);
691 printf (_("This plugin checks the amount of used disk space on a mounted file system"));
692 printf (_("and generates an alert if free space is less than one of the threshold values"));
694 printf ("\n\n");
696 print_usage ();
698 printf (_(UT_HELP_VRSN));
700 printf (" %s\n", "-w, --warning=INTEGER");
701 printf (" %s\n", _("Exit with WARNING status if less than INTEGER units of disk are free"));
702 printf (" %s\n", "-w, --warning=PERCENT%");
703 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of disk space is free"));
704 printf (" %s\n", "-W, --iwarning=PERCENT%");
705 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of inode space is free"));
706 printf (" %s\n", "-K, --icritical=PERCENT%");
707 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free"));
708 printf (" %s\n", "-c, --critical=INTEGER");
709 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER units of disk are free"));
710 printf (" %s\n", "-c, --critical=PERCENT%");
711 printf (" %s\n", _("Exit with CRITCAL status if less than PERCENT of disk space is free"));
712 printf (" %s\n", "-C, --clear");
713 printf (" %s\n", _("Clear thresholds"));
714 printf (" %s\n", "-u, --units=STRING");
715 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
716 printf (" %s\n", "-k, --kilobytes");
717 printf (" %s\n", _("Same as '--units kB'"));
718 printf (" %s\n", "-m, --megabytes");
719 printf (" %s\n", _("Same as '--units MB'"));
720 printf (" %s\n", "-l, --local");
721 printf (" %s\n", _("Only check local filesystems"));
722 printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
723 printf (" %s\n", _("Path or partition (may be repeated)"));
724 printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
725 printf (" %s\n", _("Ignore device (only works if -p unspecified)"));
726 printf (" %s\n", _("-X, --exclude-type=TYPE <STRING>"));
727 printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
728 printf (" %s\n", "-m, --mountpoint");
729 printf (" %s\n", _("Display the mountpoint instead of the partition"));
730 printf (" %s\n", "-e, --errors-only");
731 printf (" %s\n", _("Display only devices/mountpoints with errors"));
732 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
733 printf (_(UT_VERBOSE));
734 printf ("\n");
735 printf ("%s\n", _("Examples:"));
736 printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /");
737 printf (" %s\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"));
738 printf (_(UT_SUPPORT));
739 }
743 void
744 print_usage (void)
745 {
746 printf (_("Usage:"));
747 printf (" %s -w limit -c limit [-p path | -x device] [-t timeout]", progname);
748 printf ("[-m] [-e] [-W limit] [-K limit] [-v] [-q]\n");
749 }