summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1fea1e)
raw | patch | inline | side by side (parent: a1fea1e)
author | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Fri, 30 Mar 2007 08:52:28 +0000 (08:52 +0000) | ||
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Fri, 30 Mar 2007 08:52:28 +0000 (08:52 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1657 f882894a-f735-0410-b71e-b25c423dba1c
lib/utils_disk.c | patch | blob | history | |
lib/utils_disk.h | patch | blob | history | |
plugins/check_disk.c | patch | blob | history |
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index fd768b20d09c7b356075f7e5f62e5b86a69941af..877b80d91ed52db61bf2181aa84864da128cb52b 100644 (file)
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
new_path->usedspace_percent = NULL;
new_path->usedinodes_percent = NULL;
new_path->freeinodes_percent = NULL;
+ new_path->group = NULL;
if (current == NULL) {
*list = new_path;
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index 55de9385d7bacb2e6a1fc2da56779ef213437133..331c16d7d675e3169ad8a6684f745256a40549ad 100644 (file)
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
thresholds *usedspace_percent;
thresholds *usedinodes_percent;
thresholds *freeinodes_percent;
+ char *group;
struct mount_entry *best_match;
struct parameter_list *name_next;
};
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7bd044adf6dc046fe2dd460164bbd3ed3cb9abba..10095648f3bd9d14652056cedbd2e435dfbcca0e 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
char *warn_freeinodes_percent = NULL;
char *crit_freeinodes_percent = NULL;
bool path_selected = false;
+char *group = NULL;
int
int temp_result;
struct mount_entry *me;
- struct fs_usage fsp;
+ struct fs_usage fsp, tmpfsp;
struct parameter_list *temp_list, *path;
struct name_list *seen = NULL;
path = np_add_parameter(&path_select_list, me->me_mountdir);
}
path->best_match = me;
+ path->group = group;
set_all_thresholds(path);
}
}
printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end,
path->freespace_percent->critical->end);
+ if (verbose > 3 && path->group != NULL)
+ printf("Group of %s: %s\n",path->name,path->group);
+
/* reset disk result */
disk_result = STATE_UNKNOWN;
if (np_seen_name(seen, me->me_mountdir)) {
continue;
} else {
- np_add_name(&seen, me->me_mountdir);
- }
- /* Skip remote filesystems if we're not interested in them */
- if (me->me_remote && show_local_fs) {
- continue;
- /* Skip pseudo fs's if we haven't asked for all fs's */
- } else if (me->me_dummy && !show_all_fs) {
- continue;
- /* Skip excluded fstypes */
- } else if (fs_exclude_list && np_find_name (fs_exclude_list, me->me_type)) {
- continue;
- /* Skip excluded fs's */
- } else if (dp_exclude_list &&
- (np_find_name (dp_exclude_list, me->me_devname) ||
- np_find_name (dp_exclude_list, me->me_mountdir))) {
- continue;
+ if (path->group != NULL) {
+ /* find all group members */
+ fsp.fsu_blocksize = 0;
+ fsp.fsu_blocks = 0;
+ fsp.fsu_bfree = 0;
+ fsp.fsu_bavail = 0;
+ fsp.fsu_files = 0;
+ fsp.fsu_ffree = 0;
+
+
+ for (temp_list = path_select_list; temp_list; temp_list=temp_list->name_next) {
+ if (temp_list->group && ! (strcmp(temp_list->group, path->group))) {
+
+ 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 */
+ fsp.fsu_blocksize = (fsp.fsu_blocksize * fsp.fsu_blocks + tmpfsp.fsu_blocksize * tmpfsp.fsu_blocks) / \
+ (fsp.fsu_blocks + tmpfsp.fsu_blocks); /* Size of a block. */
+ fsp.fsu_blocks += tmpfsp.fsu_blocks; /* Total blocks. */
+ fsp.fsu_bfree += tmpfsp.fsu_bfree; /* Free blocks available to superuser. */
+ fsp.fsu_bavail += tmpfsp.fsu_bavail; /* Free blocks available to non-superuser. */
+ fsp.fsu_files += tmpfsp.fsu_files; /* Total file nodes. */
+ fsp.fsu_ffree += tmpfsp.fsu_ffree; /* Free file nodes. */
+
+ if (verbose > 3)
+ printf("Group %s: add %llu blocks (%s) \n", path->group, tmpfsp.fsu_bavail, temp_list->name);
+ // printf("Group %s: add %u blocks (%s)\n", temp_list->name); // path->group, tmpfsp.fsu_bavail, temp_list->name);
+
+ np_add_name(&seen, temp_list->best_match->me_mountdir);
+ }
+ }
+ /* modify devname and mountdir for output */
+ me->me_mountdir = me->me_devname = path->group;
+ } else
+ np_add_name(&seen, me->me_mountdir);
}
- get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
+ if (path->group == NULL) {
+ /* Skip remote filesystems if we're not interested in them */
+ if (me->me_remote && show_local_fs) {
+ continue;
+ /* Skip pseudo fs's if we haven't asked for all fs's */
+ } else if (me->me_dummy && !show_all_fs) {
+ continue;
+ /* Skip excluded fstypes */
+ } else if (fs_exclude_list && np_find_name (fs_exclude_list, me->me_type)) {
+ continue;
+ /* Skip excluded fs's */
+ } else if (dp_exclude_list &&
+ (np_find_name (dp_exclude_list, me->me_devname) ||
+ np_find_name (dp_exclude_list, me->me_mountdir))) {
+ continue;
+ }
+
+ get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
+ }
if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) {
total = fsp.fsu_blocks;
{"partition", required_argument, 0, 'p'},
{"exclude_device", required_argument, 0, 'x'},
{"exclude-type", required_argument, 0, 'X'},
+ {"group", required_argument, 0, 'g'},
{"mountpoint", no_argument, 0, 'M'},
{"errors-only", no_argument, 0, 'e'},
{"exact-match", no_argument, 0, 'E'},
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklME", longopts, &option);
+ c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklg:ME", longopts, &option);
if (c == -1 || c == EOF)
break;
if (! (se = np_find_parameter(path_select_list, optarg))) {
se = np_add_parameter(&path_select_list, optarg);
}
-
+ se->group = group;
set_all_thresholds(se);
path_selected = true;
break;
case 'E':
exact_match = TRUE;
break;
+ case 'g':
+ if (path_selected)
+ die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set group value before using -p\n"));
+ group = optarg;
+ break;
case 'M': /* display mountpoint */
display_mntp = TRUE;
break;
if (! (path = np_find_parameter(path_select_list, me->me_mountdir)))
path = np_add_parameter(&path_select_list, me->me_mountdir);
path->best_match = me;
+ path->group = group;
set_all_thresholds(path);
}
}
crit_freeinodes_percent = NULL;
path_selected = false;
+ group = NULL;
break;
case 'V': /* version */
print_revision (progname, revision);
printf (" %s\n", _("Only check local filesystems"));
printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
printf (" %s\n", _("Path or partition (may be repeated)"));
+ printf (" %s\n", "-g, --group=NAME");
+ printf (" %s\n", _("Group pathes. Thresholds apply to (free-)space of all partitions together"));
printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
printf (" %s\n", _("Ignore device (only works if -p unspecified)"));
printf (" %s\n", "-X, --exclude-type=TYPE <STRING>");