diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-03-12 07:05:47 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-03-12 07:05:47 +0000 |
commit | 46b0e78076a4c712f9c58b4f7804ba50b5895f46 (patch) | |
tree | 2389393a0343c0e0a98f72b046cc8aad7712a02b /plugins | |
parent | 10a9300ed850d077afb82380649a45d663b3be5d (diff) | |
download | monitoring-plugins-46b0e78076a4c712f9c58b4f7804ba50b5895f46.tar.gz |
doco standarization
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@409 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_disk.c | 130 |
1 files changed, 62 insertions, 68 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index f72841e8..485ae822 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -1,35 +1,58 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * CHECK_DISK.C | 3 | * This program is free software; you can redistribute it and/or modify |
4 | * | 4 | * it under the terms of the GNU General Public License as published by |
5 | * Program: Disk space plugin for Nagios | 5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * License: GPL | 6 | * (at your option) any later version. |
7 | * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) | 7 | * |
8 | * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) | 8 | * This program is distributed in the hope that it will be useful, |
9 | * | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * $Id$ | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * | 11 | * GNU General Public License for more details. |
12 | * Description: | 12 | * |
13 | * | 13 | * You should have received a copy of the GNU General Public License |
14 | * This plugin will use the /bin/df command to check the free space on | 14 | * along with this program; if not, write to the Free Software |
15 | * currently mounted filesystems. If the percent used disk space is | 15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * above <c_dfp>, a STATE_CRITICAL is returned. If the percent used | 16 | * |
17 | * disk space is above <w_dfp>, a STATE_WARNING is returned. If the | 17 | *****************************************************************************/ |
18 | * specified filesystem cannot be read, a STATE_CRITICAL is returned, | 18 | |
19 | * other errors with reading the output result in a STATE_UNKNOWN | 19 | const char *progname = "check_disk"; |
20 | * error. | 20 | const char *revision = "$Revision$"; |
21 | * | 21 | const char *copyright = "1999-2003"; |
22 | * Notes: | 22 | const char *authors = "Nagios Plugin Development Team"; |
23 | * - IRIX support added by Charlie Cook 4-16-1999 | 23 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
24 | * - Modifications by Karl DeBisschop 1999-11-24 | 24 | |
25 | * reformat code to 80 char screen width | 25 | const char *summary = "\ |
26 | * set STATE_WARNING if stderr is written or spclose status set | 26 | This plugin checks the amount of used disk space on a mounted file system\n\ |
27 | * set default result to STAT_UNKNOWN | 27 | and generates an alert if free space is less than one of the threshold values."; |
28 | * initailize usp to -1, eliminate 'found' variable | 28 | |
29 | * accept any filename/filesystem | 29 | const char *option_summary = "\ |
30 | * use sscanf, drop while loop | 30 | -w limit -c limit [-p path | -x device] [-t timeout] [-m] [-e]\n\ |
31 | * | 31 | [-v] [-q]"; |
32 | *****************************************************************************/ | 32 | |
33 | const char *options = "\ | ||
34 | -w, --warning=INTEGER\n\ | ||
35 | Exit with WARNING status if less than INTEGER kilobytes of disk are free\n\ | ||
36 | -w, --warning=PERCENT%%\n\ | ||
37 | Exit with WARNING status if less than PERCENT of disk space is free\n\ | ||
38 | -c, --critical=INTEGER\n\ | ||
39 | Exit with CRITICAL status if less than INTEGER kilobytes of disk are free\n\ | ||
40 | -c, --critical=PERCENT%%\n\ | ||
41 | Exit with CRITCAL status if less than PERCENT of disk space is free\n\ | ||
42 | -p, --path=PATH, --partition=PARTTION\n\ | ||
43 | Path or partition (checks all mounted partitions if unspecified)\n\ | ||
44 | -m, --mountpoint\n\ | ||
45 | Display the mountpoint instead of the partition\n\ | ||
46 | -x, --exclude_device=PATH\n\ | ||
47 | Ignore device (only works if -p unspecified)\n\ | ||
48 | -e, --errors-only\n\ | ||
49 | Display only devices/mountpoints with errors\n\ | ||
50 | -v, --verbose\n\ | ||
51 | Show details for command-line debugging (do not use with nagios server)\n\ | ||
52 | -h, --help\n\ | ||
53 | Print detailed help screen\n\ | ||
54 | -V, --version\n\ | ||
55 | Print version information\n"; | ||
33 | 56 | ||
34 | #include "common.h" | 57 | #include "common.h" |
35 | #include "popen.h" | 58 | #include "popen.h" |
@@ -44,17 +67,12 @@ | |||
44 | # include <inttypes.h> | 67 | # include <inttypes.h> |
45 | #endif | 68 | #endif |
46 | 69 | ||
47 | #define REVISION "$Revision$" | ||
48 | #define COPYRIGHT "2000-2002" | ||
49 | |||
50 | int process_arguments (int, char **); | 70 | int process_arguments (int, char **); |
51 | int validate_arguments (void); | 71 | int validate_arguments (void); |
52 | int check_disk (int usp, int free_disk); | 72 | int check_disk (int usp, int free_disk); |
53 | void print_help (void); | 73 | void print_help (void); |
54 | void print_usage (void); | 74 | void print_usage (void); |
55 | 75 | ||
56 | const char *progname = "check_disk"; | ||
57 | |||
58 | int w_df = -1; | 76 | int w_df = -1; |
59 | int c_df = -1; | 77 | int c_df = -1; |
60 | float w_dfp = -1.0; | 78 | float w_dfp = -1.0; |
@@ -327,7 +345,7 @@ process_arguments (int argc, char **argv) | |||
327 | exclude_device = optarg; | 345 | exclude_device = optarg; |
328 | break; | 346 | break; |
329 | case 'V': /* version */ | 347 | case 'V': /* version */ |
330 | print_revision (progname, REVISION); | 348 | print_revision (progname, revision); |
331 | exit (STATE_OK); | 349 | exit (STATE_OK); |
332 | case 'h': /* help */ | 350 | case 'h': /* help */ |
333 | print_help (); | 351 | print_help (); |
@@ -398,36 +416,12 @@ check_disk (usp, free_disk) | |||
398 | void | 416 | void |
399 | print_help (void) | 417 | print_help (void) |
400 | { | 418 | { |
401 | print_revision (progname, REVISION); | 419 | print_revision (progname, revision); |
402 | printf | 420 | printf ("Copyright (c) %s %s\n\t<%s>\n\n%s\n", |
403 | ("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n" | 421 | copyright, authors, email, summary); |
404 | "This plugin will check the percent of used disk space on a mounted\n" | ||
405 | "file system and generate an alert if percentage is above one of the\n" | ||
406 | "threshold values.\n\n"); | ||
407 | print_usage (); | 422 | print_usage (); |
408 | printf | 423 | printf ("\nOptions:\n"); |
409 | ("\nOptions:\n" | 424 | printf (options); |
410 | " -w, --warning=INTEGER\n" | ||
411 | " Exit with WARNING status if less than INTEGER kilobytes of disk are free\n" | ||
412 | " -w, --warning=PERCENT%%\n" | ||
413 | " Exit with WARNING status if less than PERCENT of disk space is free\n" | ||
414 | " -c, --critical=INTEGER\n" | ||
415 | " Exit with CRITICAL status if less than INTEGER kilobytes of disk are free\n" | ||
416 | " -c, --critical=PERCENT%%\n" | ||
417 | " Exit with CRITCAL status if less than PERCENT of disk space is free\n" | ||
418 | " -p, --path=PATH, --partition=PARTTION\n" | ||
419 | " Path or partition (checks all mounted partitions if unspecified)\n" | ||
420 | " -m, --mountpoint\n" | ||
421 | " Display the mountpoint instead of the partition\n" | ||
422 | " -x, --exclude_device=PATH\n" | ||
423 | " Ignore device (only works if -p unspecified)\n" | ||
424 | " -e, --errors-only\n" | ||
425 | " Display only devices/mountpoints with errors\n" | ||
426 | " -v, --verbose\n" | ||
427 | " Show details for command-line debugging (do not use with nagios server)\n" | ||
428 | " -h, --help\n" | ||
429 | " Print detailed help screen\n" | ||
430 | " -V, --version\n" " Print version information\n\n"); | ||
431 | support (); | 425 | support (); |
432 | } | 426 | } |
433 | 427 | ||
@@ -435,7 +429,7 @@ void | |||
435 | print_usage (void) | 429 | print_usage (void) |
436 | { | 430 | { |
437 | printf | 431 | printf |
438 | ("Usage: %s -w limit -c limit [-p path | -x device] [-t timeout] [-m] [-e] [--verbose]\n" | 432 | ("Usage: %s %s\n" |
439 | " %s (-h|--help)\n" | 433 | " %s (-h|--help)\n" |
440 | " %s (-V|--version)\n", progname, progname, progname); | 434 | " %s (-V|--version)\n", progname, option_summary, progname, progname); |
441 | } | 435 | } |