summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7feb5a5..7bed4d4 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1,19 +1,19 @@
1/****************************************************************************** 1/******************************************************************************
2* 2
3* This program is free software; you can redistribute it and/or modify 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 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 5 the Free Software Foundation; either version 2 of the License, or
6* (at your option) any later version. 6 (at your option) any later version.
7* 7
8* This program is distributed in the hope that it will be useful, 8 This program is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details. 11 GNU General Public License for more details.
12* 12
13* You should have received a copy of the GNU General Public License 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 14 along with this program; if not, write to the Free Software
15* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16* 16
17*****************************************************************************/ 17*****************************************************************************/
18 18
19const char *progname = "check_disk"; 19const char *progname = "check_disk";
@@ -111,7 +111,7 @@ enum
111int process_arguments (int, char **); 111int process_arguments (int, char **);
112void print_path (char *mypath); 112void print_path (char *mypath);
113int validate_arguments (uintmax_t, uintmax_t, double, double, char *); 113int validate_arguments (uintmax_t, uintmax_t, double, double, char *);
114int check_disk (int usp, uintmax_t free_disk); 114int check_disk (double usp, uintmax_t free_disk);
115int walk_name_list (struct name_list *list, const char *name); 115int walk_name_list (struct name_list *list, const char *name);
116void print_help (void); 116void print_help (void);
117void print_usage (void); 117void print_usage (void);
@@ -120,9 +120,9 @@ uintmax_t w_df = 0;
120uintmax_t c_df = 0; 120uintmax_t c_df = 0;
121double w_dfp = -1.0; 121double w_dfp = -1.0;
122double c_dfp = -1.0; 122double c_dfp = -1.0;
123char *path = ""; 123char *path;
124char *exclude_device = ""; 124char *exclude_device;
125char *units = NULL; 125char *units;
126uintmax_t mult = 1024 * 1024; 126uintmax_t mult = 1024 * 1024;
127int verbose = 0; 127int verbose = 0;
128int erronly = FALSE; 128int erronly = FALSE;
@@ -140,14 +140,17 @@ main (int argc, char **argv)
140 int result = STATE_UNKNOWN; 140 int result = STATE_UNKNOWN;
141 int disk_result = STATE_UNKNOWN; 141 int disk_result = STATE_UNKNOWN;
142 char file_system[MAX_INPUT_BUFFER]; 142 char file_system[MAX_INPUT_BUFFER];
143 char *output = ""; 143 char *output;
144 char *details = ""; 144 char *details;
145 float free_space, free_space_pct, total_space; 145 float free_space, free_space_pct, total_space;
146 146
147 struct mount_entry *me; 147 struct mount_entry *me;
148 struct fs_usage fsp; 148 struct fs_usage fsp;
149 struct name_list *temp_list; 149 struct name_list *temp_list;
150 150
151 output = strdup ("");
152 details = strdup ("");
153
151 mount_list = read_filesystem_list (0); 154 mount_list = read_filesystem_list (0);
152 155
153 if (process_arguments (argc, argv) != OK) 156 if (process_arguments (argc, argv) != OK)
@@ -414,7 +417,7 @@ process_arguments (int argc, char **argv)
414 if (c_dfp < 0 && argc > c && is_intnonneg (argv[c])) 417 if (c_dfp < 0 && argc > c && is_intnonneg (argv[c]))
415 c_dfp = (100.0 - atof (argv[c++])); 418 c_dfp = (100.0 - atof (argv[c++]));
416 419
417 if (argc > c && strlen (path) == 0) { 420 if (argc > c && path == NULL) {
418 se = (struct name_list *) malloc (sizeof (struct name_list)); 421 se = (struct name_list *) malloc (sizeof (struct name_list));
419 se->name = strdup (argv[c++]); 422 se->name = strdup (argv[c++]);
420 se->name_next = NULL; 423 se->name_next = NULL;
@@ -482,7 +485,7 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
482 485
483 486
484int 487int
485check_disk (int usp, uintmax_t free_disk) 488check_disk (double usp, uintmax_t free_disk)
486{ 489{
487 int result = STATE_UNKNOWN; 490 int result = STATE_UNKNOWN;
488 /* check the percent used space against thresholds */ 491 /* check the percent used space against thresholds */