Code

Fixed bug with malloc of wrong size
[nagiosplug.git] / plugins / check_disk.c
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$
18  
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
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)
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;
297 /* process command-line arguments */
298 int
299 process_arguments (int argc, char **argv)
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->found = 0;
466       se->found_len = 0;
467       *pathtail = se;
468       pathtail = &se->name_next;
469       break;
470     case 'x':                 /* exclude path or partition */
471       se = (struct name_list *) malloc (sizeof (struct name_list));
472       se->name = optarg;
473       se->name_next = NULL;
475                         /* If you don't clear the w_fd etc values here, they
476                          * get processed when you walk the list and assigned
477                          * to the global w_df!
478                          */
479                         se->w_df = 0;
480                         se->c_df = 0;
481                         se->w_dfp = 0;
482                         se->c_dfp = 0;
483       se->found = 0;
484       se->found_len = 0;
485       *dptail = se;
486       dptail = &se->name_next;
487       break;
488     case 'X':                 /* exclude file system type */
489       se = (struct name_list *) malloc (sizeof (struct name_list));
490       se->name = optarg;
491       se->name_next = NULL;
492                         /* If you don't clear the w_fd etc values here, they
493                          * get processed when you walk the list and assigned
494                          * to the global w_df!
495                          */
496                         se->w_df = 0;
497                         se->c_df = 0;
498                         se->w_dfp = 0;
499                         se->c_dfp = 0;
500       se->found = 0;
501       se->found_len = 0;
502       *fstail = se;
503       fstail = &se->name_next;
504       break;
505     case 'v':                 /* verbose */
506       verbose++;
507       break;
508     case 'q':                 /* verbose */
509       verbose--;
510       break;
511     case 'e':
512       erronly = TRUE;
513       break;
514     case 'M': /* display mountpoint */
515       display_mntp = TRUE;
516       break;
517     case 'C':
518       w_df = 0;
519       c_df = 0;
520       w_dfp = -1.0;
521       c_dfp = -1.0;
522       break;
523     case 'V':                 /* version */
524       print_revision (progname, revision);
525       exit (STATE_OK);
526     case 'h':                 /* help */
527       print_help ();
528       exit (STATE_OK);
529     case '?':                 /* help */
530       usage (_("Unknown argument"));
531     }
532   }
534   /* Support for "check_disk warn crit [fs]" with thresholds at used level */
535   c = optind;
536   if (w_dfp < 0 && argc > c && is_intnonneg (argv[c]))
537     w_dfp = (100.0 - atof (argv[c++]));
539   if (c_dfp < 0 && argc > c && is_intnonneg (argv[c]))
540     c_dfp = (100.0 - atof (argv[c++]));
542   if (argc > c && path == NULL) {
543     se = (struct name_list *) malloc (sizeof (struct name_list));
544     se->name = strdup (argv[c++]);
545     se->name_next = NULL;
546     se->w_df = w_df;
547     se->c_df = c_df;
548     se->w_dfp = w_dfp;
549     se->c_dfp = c_dfp;
550     se->found =0;
551     se->found_len = 0;
552     *pathtail = se;
553   }
555   if (path_select_list) {
556     temp_list = path_select_list;
557     stat_buf = malloc(sizeof *stat_buf);
558     while (temp_list) {
559       /* Stat each entry to check that dir exists */
560       if (stat (temp_list->name, &stat_buf[0])) {
561         printf("DISK %s - ", _("CRITICAL"));
562         die (STATE_CRITICAL, _("%s does not exist\n"), temp_list->name);
563       }
564       if (validate_arguments (temp_list->w_df,
565                               temp_list->c_df,
566                               temp_list->w_dfp,
567                               temp_list->c_dfp,
568                               temp_list->w_idfp,
569                               temp_list->c_idfp,
570                               temp_list->name) == ERROR)
571         result = ERROR;
572       temp_list = temp_list->name_next;
573     }
574     free(stat_buf);
575     return result;
576   } else {
577     return validate_arguments (w_df, c_df, w_dfp, c_dfp, w_idfp, c_idfp, NULL);
578   }
583 void
584 print_path (const char *mypath) 
586   if (mypath == NULL)
587     printf ("\n");
588   else
589     printf (_(" for %s\n"), mypath);
591   return;
596 int
597 validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, double iwp, double icp, char *mypath)
599   if (w < 0 && c < 0 && wp < 0.0 && cp < 0.0) {
600     printf (_("INPUT ERROR: No thresholds specified"));
601     print_path (mypath);
602     return ERROR;
603   }
604   else if ((wp >= 0.0 || cp >= 0.0) &&
605            (wp < 0.0 || cp < 0.0 || wp > 100.0 || cp > 100.0 || cp > wp)) {
606     printf (_("\
607 INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
608             cp, wp);
609     print_path (mypath);
610     return ERROR;
611   }
612   else if ((iwp >= 0.0 || icp >= 0.0) &&
613            (iwp < 0.0 || icp < 0.0 || iwp > 100.0 || icp > 100.0 || icp > iwp)) {
614     printf (_("\
615 INPUT ERROR: C_IDFP (%f) should be less than W_IDFP (%.1f) and both should be between zero and 100 percent, inclusive"),
616             icp, iwp);
617     print_path (mypath);
618     return ERROR;
619   }
620   else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) {
621     printf (_("\
622 INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
623             (unsigned long)c, (unsigned long)w);
624     print_path (mypath);
625     return ERROR;
626   }
627   
628   if (units == NULL) {
629     units = strdup ("MB");
630     mult = (uintmax_t)1024 * 1024;
631   }
632   return OK;
637 int
639 check_disk (double usp, uintmax_t free_disk, double uisp)
641        int result = STATE_UNKNOWN;
642        /* check the percent used space against thresholds */
643        if (usp >= 0.0 && c_dfp >=0.0 && usp >= (100.0 - c_dfp))
644                result = STATE_CRITICAL;
645        else if (uisp >= 0.0 && c_idfp >=0.0 && uisp >= (100.0 - c_idfp))
646                result = STATE_CRITICAL;
647        else if (c_df > 0 && free_disk <= c_df)
648                result = STATE_CRITICAL;
649        else if (usp >= 0.0 && w_dfp >=0.0 && usp >= (100.0 - w_dfp))
650                result = STATE_WARNING;
651        else if (uisp >= 0.0 && w_idfp >=0.0 && uisp >= (100.0 - w_idfp))
652                result = STATE_WARNING;
653        else if (w_df > 0 && free_disk <= w_df)
654                result = STATE_WARNING;
655        else if (usp >= 0.0)
656     result = STATE_OK;
657   return result;
662 int
663 walk_name_list (struct name_list *list, const char *name)
665   int name_len;
666   name_len = strlen(name);
667   while (list) {
668     /* if the paths match up to the length of the mount path,
669      * AND if the mount path name is longer than the longest
670      * found match, we have a new winner */
671     if (name_len >= list->found_len && 
672         ! strncmp(list->name, name, name_len)) {
673       list->found = 1;
674       list->found_len = name_len;
675       /* if required for name_lists that have not saved w_df, etc (eg exclude lists) */
676       if (list->w_df) w_df = list->w_df;
677       if (list->c_df) c_df = list->c_df;
678       if (list->w_dfp>=0.0) w_dfp = list->w_dfp;
679       if (list->c_dfp>=0.0) c_dfp = list->c_dfp;
680       return TRUE;
681     }
682     list = list->name_next;
683   }
684   return FALSE;
689 void
690 print_help (void)
692   print_revision (progname, revision);
694   printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
695   printf (COPYRIGHT, copyright, email);
697   printf (_("This plugin checks the amount of used disk space on a mounted file system"));
698   printf (_("and generates an alert if free space is less than one of the threshold values"));
700   printf ("\n\n");
702   print_usage ();
704   printf (_(UT_HELP_VRSN));
706   printf (" %s\n", "-w, --warning=INTEGER");
707   printf ("    %s\n", _("Exit with WARNING status if less than INTEGER units of disk are free"));
708   printf (" %s\n", "-w, --warning=PERCENT%");
709   printf ("    %s\n", _("Exit with WARNING status if less than PERCENT of disk space is free"));
710   printf (" %s\n", "-W, --iwarning=PERCENT%");
711   printf ("    %s\n", _("Exit with WARNING status if less than PERCENT of inode space is free"));
712   printf (" %s\n", "-K, --icritical=PERCENT%");
713   printf ("    %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free"));
714   printf (" %s\n", "-c, --critical=INTEGER");
715   printf ("    %s\n", _("Exit with CRITICAL status if less than INTEGER units of disk are free"));
716   printf (" %s\n", "-c, --critical=PERCENT%");
717   printf ("    %s\n", _("Exit with CRITCAL status if less than PERCENT of disk space is free"));
718   printf (" %s\n", "-C, --clear");
719   printf ("    %s\n", _("Clear thresholds"));
720   printf (" %s\n", "-u, --units=STRING");
721   printf ("    %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
722   printf (" %s\n", "-k, --kilobytes");
723   printf ("    %s\n", _("Same as '--units kB'"));
724   printf (" %s\n", "-m, --megabytes");
725   printf ("    %s\n", _("Same as '--units MB'"));
726   printf (" %s\n", "-l, --local");
727   printf ("    %s\n", _("Only check local filesystems"));
728   printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
729   printf ("    %s\n", _("Path or partition (may be repeated)"));
730   printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
731   printf ("    %s\n", _("Ignore device (only works if -p unspecified)"));
732   printf (" %s\n", _("-X, --exclude-type=TYPE <STRING>"));
733   printf ("    %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
734   printf (" %s\n", "-m, --mountpoint");
735   printf ("    %s\n", _("Display the mountpoint instead of the partition"));
736   printf (" %s\n", "-e, --errors-only");
737   printf ("    %s\n", _("Display only devices/mountpoints with errors"));
738   printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
739   printf (_(UT_VERBOSE));
740   printf ("\n");
741   printf ("%s\n", _("Examples:"));
742   printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /");
743   printf ("    %s\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"));
744   printf (_(UT_SUPPORT));
749 void
750 print_usage (void)
752   printf (_("Usage:"));
753   printf (" %s -w limit -c limit [-p path | -x device] [-t timeout]", progname);
754   printf ("[-m] [-e] [-W limit] [-K limit] [-v] [-q]\n");