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