check_disk.c 19 KB

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