summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2b5611e)
raw | patch | inline | side by side (parent: 2b5611e)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Wed, 25 Jun 2003 15:43:31 +0000 (15:43 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Wed, 25 Jun 2003 15:43:31 +0000 (15:43 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@557 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_disk.c | patch | blob | history |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index fd3b9770a93b014aa7ca117ee603a112a42b9516..2b285d3eb0c71219e46f64d1df1c8e1f7194bd8b 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
Display the mountpoint instead of the partition\n\
-e, --errors-only\n\
Display only devices/mountpoints with errors\n\
+ -C, --clear\n\
+ Clear thresholds\n\
-v, --verbose\n\
Show details for command-line debugging (do not use with nagios server)\n\
-h, --help\n\
const char *notes = "\
\n";
+const char *examples = "\
+ check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n\
+ Checks /tmp and /var at 10%,5% and / at 100MB, 50MB\n\
+\n";
+
#include "common.h"
#if HAVE_INTTYPES_H
# include <inttypes.h>
{
char *name;
int found;
+ int w_df;
+ int c_df;
+ float w_dfp;
+ float c_dfp;
struct name_list *name_next;
};
#endif
int process_arguments (int, char **);
-int validate_arguments (void);
+int validate_arguments (int, int, float, float, char *);
int check_disk (int usp, int free_disk);
int walk_name_list (struct name_list *list, const char *name);
void print_help (void);
units,
free_space_pct,
(!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
- asprintf (&details, "%s\n%.0f of %.0f %s (%2.0f%%) free on %s (type %s mounted on %s)",
+ asprintf (&details, "%s\n%.0f of %.0f %s (%2.0f%%) free on %s (type %s mounted on %s) warn:%d crit:%d warn%%:%.0f%% crit%%:%.0f%%",
details,
free_space,
total_space,
free_space_pct,
me->me_devname,
me->me_type,
- me->me_mountdir);
+ me->me_mountdir,
+ w_df, c_df, w_dfp, c_dfp);
}
}
struct name_list **devtail = &dev_select_list;
struct name_list **fstail = &fs_exclude_list;
struct name_list **dptail = &dp_exclude_list;
+ struct name_list *temp_list;
+ int result = OK;
int option_index = 0;
static struct option long_options[] = {
{"errors-only", no_argument, 0, 'e'},
{"verbose", no_argument, 0, 'v'},
{"quiet", no_argument, 0, 'q'},
+ {"clear", no_argument, 0, 'C'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "+?Vqhvet:c:w:u:p:x:X:mklM", long_options, &option_index);
+ c = getopt_long (argc, argv, "+?VqhveCt:c:w:u:p:x:X:mklM", long_options, &option_index);
if (c == -1 || c == EOF)
break;
se = (struct name_list *) malloc (sizeof (struct name_list));
se->name = strdup (optarg);
se->name_next = NULL;
+ se->w_df = w_df;
+ se->c_df = c_df;
+ se->w_dfp = w_dfp;
+ se->c_dfp = c_dfp;
*pathtail = se;
pathtail = &se->name_next;
break;
case 'M': /* display mountpoint */
display_mntp = TRUE;
break;
+ case 'C':
+ w_df = -1;
+ c_df = -1;
+ w_dfp = -1.0;
+ c_dfp = -1.0;
+ break;
case 'V': /* version */
print_revision (progname, revision);
exit (STATE_OK);
if (argc > c && strlen (path) == 0)
path = argv[c++];
- return validate_arguments ();
+ if (path_select_list) {
+ temp_list = path_select_list;
+ while (temp_list) {
+ if (validate_arguments (temp_list->w_df, temp_list->c_df, temp_list->w_dfp, temp_list->c_dfp, temp_list->name) == ERROR)
+ result = ERROR;
+ temp_list = temp_list->name_next;
+ }
+ return result;
+ } else {
+ return validate_arguments (w_df, c_df, w_dfp, c_dfp, NULL);
+ }
}
+void print_path (char *path)
+{
+ if (path)
+ printf (" for %s", path);
+ printf ("\n");
+}
int
-validate_arguments ()
+validate_arguments (int w, int c, float wp, float cp, char *path)
{
- if (w_df < 0 && c_df < 0 && w_dfp < 0 && c_dfp < 0) {
- printf ("INPUT ERROR: Unable to parse command line\n");
+ if (w < 0 && c < 0 && wp < 0 && cp < 0) {
+ printf ("INPUT ERROR: No thresholds specified");
+ print_path (path);
return ERROR;
}
- else if ((w_dfp >= 0 || c_dfp >= 0)
- && (w_dfp < 0 || c_dfp < 0 || w_dfp > 100 || c_dfp > 100
- || c_dfp > w_dfp)) {
+ else if ((wp >= 0 || cp >= 0)
+ && (wp < 0 || cp < 0 || wp > 100 || cp > 100
+ || cp > wp)) {
printf
- ("INPUT ERROR: C_DFP (%f) should be less than W_DFP (%f) and both should be between zero and 100 percent, inclusive\n",
- c_dfp, w_dfp);
+ ("INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive",
+ cp, wp);
+ print_path (path);
return ERROR;
}
- else if ((w_df > 0 || c_df > 0) && (w_df < 0 || c_df < 0 || c_df > w_df)) {
+ else if ((w > 0 || c > 0) && (w < 0 || c < 0 || c > w)) {
printf
- ("INPUT ERROR: C_DF (%d) should be less than W_DF (%d) and both should be greater than zero\n",
- c_df, w_df);
+ ("INPUT ERROR: C_DF (%d) should be less than W_DF (%d) and both should be greater than zero",
+ c, w);
+ print_path (path);
return ERROR;
}
else {
while (list) {
if (! strcmp(list->name, name)) {
list->found = 1;
+ w_df = list->w_df;
+ c_df = list->c_df;
+ w_dfp = list->w_dfp;
+ c_dfp = list->c_dfp;
return TRUE;
}
list = list->name_next;
printf ("\nOptions:\n");
printf (options);
printf (notes);
+ printf ("Examples:\n%s", examples);
support ();
}