summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS14
-rw-r--r--plugins/check_disk.c41
2 files changed, 40 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index a2a4868..5b0981e 100644
--- a/NEWS
+++ b/NEWS
@@ -8,7 +8,15 @@ This file documents the major additions and syntax changes between releases.
8 is now deprecated. See --help for further information. 8 is now deprecated. See --help for further information.
9 Check_disk now calls stat() on all filesystems to check. (Old: only the ones selected using -p) 9 Check_disk now calls stat() on all filesystems to check. (Old: only the ones selected using -p)
10 A meaningful error message (eg "Stale NFS Handle") is printed if stat fails. 10 A meaningful error message (eg "Stale NFS Handle") is printed if stat fails.
11 New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
12 Thus accessibility of remote filesystems can be checked without any threshold comparison.
11 Check_disk's --help now prints some examples for the new features introduced in 1.4.8 13 Check_disk's --help now prints some examples for the new features introduced in 1.4.8
14 New check_disk -i/-I option to ignore pathes/partitions based on regular expressions
15 New check_disk -A option to select all filesystems explicitly
16 WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
17 Passing -E after -p or -r results in UNKNOWN state, now
18 This is needed due to the new ignore feature
19 Fix check_disk bug when mixing case sensitive and case insensitive regex arguments
12 New check_dhcp -u/--unicast option for emulating a DHCP relay in order 20 New check_dhcp -u/--unicast option for emulating a DHCP relay in order
13 to check DHCP servers on remote networks 21 to check DHCP servers on remote networks
14 New check_dhcp -m/--mac option which allows for specifying the MAC 22 New check_dhcp -m/--mac option which allows for specifying the MAC
@@ -20,12 +28,6 @@ This file documents the major additions and syntax changes between releases.
20 - stop evaluating command line options through shell twice 28 - stop evaluating command line options through shell twice
21 - enforce a full path for the command to run 29 - enforce a full path for the command to run
22 The "negate" utility can now remap custom states 30 The "negate" utility can now remap custom states
23 New check_disk -i/-I option to ignore pathes/partitions based on regular expressions
24 New check_disk -A option to select all filesystems explicitly
25 WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
26 Passing -E after -p or -r results in UNKNOWN state, now
27 This is needed due to the new ignore feature
28 Fix check_disk bug when mixing case sensitive and case insensitive regex arguments
29 Check_radius now supports radiusclient-ng 31 Check_radius now supports radiusclient-ng
30 32
311.4.9 4th June 2006 331.4.9 4th June 2006
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 088c589..c9c9adc 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -69,6 +69,9 @@ static int show_all_fs = 1;
69/* If nonzero, show only local filesystems. */ 69/* If nonzero, show only local filesystems. */
70static int show_local_fs = 0; 70static int show_local_fs = 0;
71 71
72/* If nonzero, show only local filesystems but call stat() on remote ones. */
73static int stat_remote_fs = 0;
74
72/* If positive, the units to use when printing sizes; 75/* If positive, the units to use when printing sizes;
73 if negative, the human-readable base. */ 76 if negative, the human-readable base. */
74/* static int output_block_size; */ 77/* static int output_block_size; */
@@ -127,6 +130,7 @@ int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, ch
127void print_help (void); 130void print_help (void);
128void print_usage (void); 131void print_usage (void);
129double calculate_percent(uintmax_t, uintmax_t); 132double calculate_percent(uintmax_t, uintmax_t);
133void stat_path (struct parameter_list *p);
130 134
131double w_dfp = -1.0; 135double w_dfp = -1.0;
132double c_dfp = -1.0; 136double c_dfp = -1.0;
@@ -152,6 +156,7 @@ char *warn_freeinodes_percent = NULL;
152char *crit_freeinodes_percent = NULL; 156char *crit_freeinodes_percent = NULL;
153int path_selected = FALSE; 157int path_selected = FALSE;
154char *group = NULL; 158char *group = NULL;
159struct stat *stat_buf;
155 160
156 161
157int 162int
@@ -176,12 +181,12 @@ main (int argc, char **argv)
176 struct fs_usage fsp, tmpfsp; 181 struct fs_usage fsp, tmpfsp;
177 struct parameter_list *temp_list, *path; 182 struct parameter_list *temp_list, *path;
178 struct name_list *seen = NULL; 183 struct name_list *seen = NULL;
179 struct stat *stat_buf;
180 184
181 preamble = strdup (" - free space:"); 185 preamble = strdup (" - free space:");
182 output = strdup (""); 186 output = strdup ("");
183 details = strdup (""); 187 details = strdup ("");
184 perf = strdup (""); 188 perf = strdup ("");
189 stat_buf = malloc(sizeof *stat_buf);
185 190
186 setlocale (LC_ALL, ""); 191 setlocale (LC_ALL, "");
187 bindtextdomain (PACKAGE, LOCALEDIR); 192 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -210,20 +215,13 @@ main (int argc, char **argv)
210 /* Error if no match found for specified paths */ 215 /* Error if no match found for specified paths */
211 temp_list = path_select_list; 216 temp_list = path_select_list;
212 217
213 stat_buf = malloc(sizeof *stat_buf);
214 while (temp_list) { 218 while (temp_list) {
215 if (! temp_list->best_match) { 219 if (! temp_list->best_match) {
216 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); 220 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name);
217 } 221 }
218 222
219 /* Stat each entry to check that dir exists */
220 if (stat (temp_list->name, &stat_buf[0])) {
221 printf("DISK %s - ", _("CRITICAL"));
222 die (STATE_CRITICAL, _("%s %s: %s\n"), temp_list->name, _("is not accessible"), strerror(errno));
223 }
224 temp_list = temp_list->name_next; 223 temp_list = temp_list->name_next;
225 } 224 }
226 free(stat_buf);
227 225
228 /* Process for every path in list */ 226 /* Process for every path in list */
229 for (path = path_select_list; path; path=path->name_next) { 227 for (path = path_select_list; path; path=path->name_next) {
@@ -259,6 +257,7 @@ main (int argc, char **argv)
259 for (temp_list = path_select_list; temp_list; temp_list=temp_list->name_next) { 257 for (temp_list = path_select_list; temp_list; temp_list=temp_list->name_next) {
260 if (temp_list->group && ! (strcmp(temp_list->group, path->group))) { 258 if (temp_list->group && ! (strcmp(temp_list->group, path->group))) {
261 259
260 stat_path(path);
262 get_fs_usage (temp_list->best_match->me_mountdir, temp_list->best_match->me_devname, &tmpfsp); 261 get_fs_usage (temp_list->best_match->me_mountdir, temp_list->best_match->me_devname, &tmpfsp);
263 262
264 /* possibly differing blocksizes if disks are grouped. Calculating average */ 263 /* possibly differing blocksizes if disks are grouped. Calculating average */
@@ -286,6 +285,8 @@ main (int argc, char **argv)
286 if (path->group == NULL) { 285 if (path->group == NULL) {
287 /* Skip remote filesystems if we're not interested in them */ 286 /* Skip remote filesystems if we're not interested in them */
288 if (me->me_remote && show_local_fs) { 287 if (me->me_remote && show_local_fs) {
288 if (stat_remote_fs)
289 stat_path(path);
289 continue; 290 continue;
290 /* Skip pseudo fs's if we haven't asked for all fs's */ 291 /* Skip pseudo fs's if we haven't asked for all fs's */
291 } else if (me->me_dummy && !show_all_fs) { 292 } else if (me->me_dummy && !show_all_fs) {
@@ -300,6 +301,7 @@ main (int argc, char **argv)
300 continue; 301 continue;
301 } 302 }
302 303
304 stat_path(path);
303 get_fs_usage (me->me_mountdir, me->me_devname, &fsp); 305 get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
304 } 306 }
305 307
@@ -467,6 +469,7 @@ process_arguments (int argc, char **argv)
467 /* Dang, -C is taken. We might want to reshuffle this. */ 469 /* Dang, -C is taken. We might want to reshuffle this. */
468 {"icritical", required_argument, 0, 'K'}, 470 {"icritical", required_argument, 0, 'K'},
469 {"local", required_argument, 0, 'l'}, 471 {"local", required_argument, 0, 'l'},
472 {"stat-remote-fs", required_argument, 0, 'L'},
470 {"kilobytes", required_argument, 0, 'k'}, 473 {"kilobytes", required_argument, 0, 'k'},
471 {"megabytes", required_argument, 0, 'm'}, 474 {"megabytes", required_argument, 0, 'm'},
472 {"units", required_argument, 0, 'u'}, 475 {"units", required_argument, 0, 'u'},
@@ -505,7 +508,7 @@ process_arguments (int argc, char **argv)
505 strcpy (argv[c], "-t"); 508 strcpy (argv[c], "-t");
506 509
507 while (1) { 510 while (1) {
508 c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklg:R:r:i:I:MEA", longopts, &option); 511 c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklLg:R:r:i:I:MEA", longopts, &option);
509 512
510 if (c == -1 || c == EOF) 513 if (c == -1 || c == EOF)
511 break; 514 break;
@@ -608,6 +611,8 @@ process_arguments (int argc, char **argv)
608 free(units); 611 free(units);
609 units = strdup ("MB"); 612 units = strdup ("MB");
610 break; 613 break;
614 case 'L':
615 stat_remote_fs = 1;
611 case 'l': 616 case 'l':
612 show_local_fs = 1; 617 show_local_fs = 1;
613 break; 618 break;
@@ -626,6 +631,7 @@ process_arguments (int argc, char **argv)
626 se->group = group; 631 se->group = group;
627 set_all_thresholds(se); 632 set_all_thresholds(se);
628 np_set_best_match(se, mount_list, exact_match); 633 np_set_best_match(se, mount_list, exact_match);
634 stat_path(se);
629 path_selected = TRUE; 635 path_selected = TRUE;
630 break; 636 break;
631 case 'x': /* exclude path or partition */ 637 case 'x': /* exclude path or partition */
@@ -914,6 +920,9 @@ print_help (void)
914 printf (" %s\n", _("Same as '--units kB'")); 920 printf (" %s\n", _("Same as '--units kB'"));
915 printf (" %s\n", "-l, --local"); 921 printf (" %s\n", "-l, --local");
916 printf (" %s\n", _("Only check local filesystems")); 922 printf (" %s\n", _("Only check local filesystems"));
923 printf (" %s\n", "-L, --stat-remote-fs");
924 printf (" %s\n", _("Only check local filesystems against thresholds. Yet call stat on remote filesystems"));
925 printf (" %s\n", _("to test if they are accessible (e.g. to detect Stale NFS Handles)"));
917 printf (" %s\n", "-M, --mountpoint"); 926 printf (" %s\n", "-M, --mountpoint");
918 printf (" %s\n", _("Display the mountpoint instead of the partition")); 927 printf (" %s\n", _("Display the mountpoint instead of the partition"));
919 printf (" %s\n", "-m, --megabytes"); 928 printf (" %s\n", "-m, --megabytes");
@@ -956,3 +965,17 @@ print_usage (void)
956 printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); 965 printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
957 printf ("[-t timeout] [-u unit] [-v] [-X type]\n"); 966 printf ("[-t timeout] [-u unit] [-v] [-X type]\n");
958} 967}
968
969void
970stat_path (struct parameter_list *p)
971{
972 /* Stat entry to check that dir exists and is accessible */
973 if (verbose > 3)
974 printf("calling stat on %s\n", p->name);
975 if (stat (p->name, &stat_buf[0])) {
976 if (verbose > 3)
977 printf("stat failed on %s\n", p->name);
978 printf("DISK %s - ", _("CRITICAL"));
979 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno));
980 }
981}