[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1789] nagiosplug/trunk
psychotrahe at users.sourceforge.net
psychotrahe at users.sourceforge.net
Sun Sep 23 12:58:10 CEST 2007
Revision: 1789
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1789&view=rev
Author: psychotrahe
Date: 2007-09-23 03:58:09 -0700 (Sun, 23 Sep 2007)
Log Message:
-----------
Fixed bug: stat was called on remote fs even if -l was given
Added -L option to call stat on remote fs but without threshold comparison
Modified Paths:
--------------
nagiosplug/trunk/NEWS
nagiosplug/trunk/plugins/check_disk.c
Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS 2007-09-23 09:48:37 UTC (rev 1788)
+++ nagiosplug/trunk/NEWS 2007-09-23 10:58:09 UTC (rev 1789)
@@ -8,7 +8,15 @@
is now deprecated. See --help for further information.
Check_disk now calls stat() on all filesystems to check. (Old: only the ones selected using -p)
A meaningful error message (eg "Stale NFS Handle") is printed if stat fails.
+ New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
+ Thus accessibility of remote filesystems can be checked without any threshold comparison.
Check_disk's --help now prints some examples for the new features introduced in 1.4.8
+ New check_disk -i/-I option to ignore pathes/partitions based on regular expressions
+ New check_disk -A option to select all filesystems explicitly
+ WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
+ Passing -E after -p or -r results in UNKNOWN state, now
+ This is needed due to the new ignore feature
+ Fix check_disk bug when mixing case sensitive and case insensitive regex arguments
New check_dhcp -u/--unicast option for emulating a DHCP relay in order
to check DHCP servers on remote networks
New check_dhcp -m/--mac option which allows for specifying the MAC
@@ -20,12 +28,6 @@
- stop evaluating command line options through shell twice
- enforce a full path for the command to run
The "negate" utility can now remap custom states
- New check_disk -i/-I option to ignore pathes/partitions based on regular expressions
- New check_disk -A option to select all filesystems explicitly
- WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
- Passing -E after -p or -r results in UNKNOWN state, now
- This is needed due to the new ignore feature
- Fix check_disk bug when mixing case sensitive and case insensitive regex arguments
Check_radius now supports radiusclient-ng
1.4.9 4th June 2006
Modified: nagiosplug/trunk/plugins/check_disk.c
===================================================================
--- nagiosplug/trunk/plugins/check_disk.c 2007-09-23 09:48:37 UTC (rev 1788)
+++ nagiosplug/trunk/plugins/check_disk.c 2007-09-23 10:58:09 UTC (rev 1789)
@@ -69,6 +69,9 @@
/* If nonzero, show only local filesystems. */
static int show_local_fs = 0;
+/* If nonzero, show only local filesystems but call stat() on remote ones. */
+static int stat_remote_fs = 0;
+
/* If positive, the units to use when printing sizes;
if negative, the human-readable base. */
/* static int output_block_size; */
@@ -127,6 +130,7 @@
void print_help (void);
void print_usage (void);
double calculate_percent(uintmax_t, uintmax_t);
+void stat_path (struct parameter_list *p);
double w_dfp = -1.0;
double c_dfp = -1.0;
@@ -152,6 +156,7 @@
char *crit_freeinodes_percent = NULL;
int path_selected = FALSE;
char *group = NULL;
+struct stat *stat_buf;
int
@@ -176,12 +181,12 @@
struct fs_usage fsp, tmpfsp;
struct parameter_list *temp_list, *path;
struct name_list *seen = NULL;
- struct stat *stat_buf;
preamble = strdup (" - free space:");
output = strdup ("");
details = strdup ("");
perf = strdup ("");
+ stat_buf = malloc(sizeof *stat_buf);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@@ -210,20 +215,13 @@
/* Error if no match found for specified paths */
temp_list = path_select_list;
- stat_buf = malloc(sizeof *stat_buf);
while (temp_list) {
if (! temp_list->best_match) {
die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name);
}
- /* Stat each entry to check that dir exists */
- if (stat (temp_list->name, &stat_buf[0])) {
- printf("DISK %s - ", _("CRITICAL"));
- die (STATE_CRITICAL, _("%s %s: %s\n"), temp_list->name, _("is not accessible"), strerror(errno));
- }
temp_list = temp_list->name_next;
}
- free(stat_buf);
/* Process for every path in list */
for (path = path_select_list; path; path=path->name_next) {
@@ -259,6 +257,7 @@
for (temp_list = path_select_list; temp_list; temp_list=temp_list->name_next) {
if (temp_list->group && ! (strcmp(temp_list->group, path->group))) {
+ stat_path(path);
get_fs_usage (temp_list->best_match->me_mountdir, temp_list->best_match->me_devname, &tmpfsp);
/* possibly differing blocksizes if disks are grouped. Calculating average */
@@ -286,6 +285,8 @@
if (path->group == NULL) {
/* Skip remote filesystems if we're not interested in them */
if (me->me_remote && show_local_fs) {
+ if (stat_remote_fs)
+ stat_path(path);
continue;
/* Skip pseudo fs's if we haven't asked for all fs's */
} else if (me->me_dummy && !show_all_fs) {
@@ -300,6 +301,7 @@
continue;
}
+ stat_path(path);
get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
}
@@ -467,6 +469,7 @@
/* Dang, -C is taken. We might want to reshuffle this. */
{"icritical", required_argument, 0, 'K'},
{"local", required_argument, 0, 'l'},
+ {"stat-remote-fs", required_argument, 0, 'L'},
{"kilobytes", required_argument, 0, 'k'},
{"megabytes", required_argument, 0, 'm'},
{"units", required_argument, 0, 'u'},
@@ -505,7 +508,7 @@
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklg:R:r:i:I:MEA", longopts, &option);
+ c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklLg:R:r:i:I:MEA", longopts, &option);
if (c == -1 || c == EOF)
break;
@@ -608,6 +611,8 @@
free(units);
units = strdup ("MB");
break;
+ case 'L':
+ stat_remote_fs = 1;
case 'l':
show_local_fs = 1;
break;
@@ -626,6 +631,7 @@
se->group = group;
set_all_thresholds(se);
np_set_best_match(se, mount_list, exact_match);
+ stat_path(se);
path_selected = TRUE;
break;
case 'x': /* exclude path or partition */
@@ -914,6 +920,9 @@
printf (" %s\n", _("Same as '--units kB'"));
printf (" %s\n", "-l, --local");
printf (" %s\n", _("Only check local filesystems"));
+ printf (" %s\n", "-L, --stat-remote-fs");
+ printf (" %s\n", _("Only check local filesystems against thresholds. Yet call stat on remote filesystems"));
+ printf (" %s\n", _("to test if they are accessible (e.g. to detect Stale NFS Handles)"));
printf (" %s\n", "-M, --mountpoint");
printf (" %s\n", _("Display the mountpoint instead of the partition"));
printf (" %s\n", "-m, --megabytes");
@@ -956,3 +965,17 @@
printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
printf ("[-t timeout] [-u unit] [-v] [-X type]\n");
}
+
+void
+stat_path (struct parameter_list *p)
+{
+ /* Stat entry to check that dir exists and is accessible */
+ if (verbose > 3)
+ printf("calling stat on %s\n", p->name);
+ if (stat (p->name, &stat_buf[0])) {
+ if (verbose > 3)
+ printf("stat failed on %s\n", p->name);
+ printf("DISK %s - ", _("CRITICAL"));
+ die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno));
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list