summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0e138a6)
raw | patch | inline | side by side (parent: 0e138a6)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 21 Mar 2003 14:08:01 +0000 (14:08 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 21 Mar 2003 14:08:01 +0000 (14:08 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@444 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 f9a9a8476aad9c5d9a9e8d57465e53bcaaa3fd5e..97465113fe3065a89b16608a135351548d3e55c1 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
/* A filesystem type to display. */
-struct fs_type_list
+struct name_list
{
- char *fs_name;
- struct fs_type_list *fs_next;
+ char *name;
+ struct name_list *name_next;
};
/* Linked list of filesystem types to display.
Some filesystem types:
4.2 4.3 ufs nfs swap ignore io vm efs dbg */
-static struct fs_type_list *fs_select_list;
+static struct name_list *fs_select_list;
/* Linked list of filesystem types to omit.
If the list is empty, don't exclude any types. */
-static struct fs_type_list *fs_exclude_list;
+static struct name_list *fs_exclude_list;
+
+static struct name_list *path_select_list;
+
+static struct name_list *dev_select_list;
/* Linked list of mounted filesystems. */
static struct mount_entry *mount_list;
struct fs_usage fsp;
char *disk;
+ mount_list = read_filesystem_list (0);
+
if (process_arguments (argc, argv) != OK)
usage ("Could not parse arguments\n");
- mount_list = read_filesystem_list (0);
-
for (me = mount_list; me; me = me->me_next) {
- get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
+
+ if ((dev_select_list &&
+ ! strcmp (dev_select_list->name, me->me_devname)) ||
+ (path_select_list &&
+ ! strcmp (path_select_list->name, me->me_mountdir)))
+ get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
+ else if (dev_select_list || path_select_list)
+ continue;
+ else
+ get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
+
if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) {
usp = (fsp.fsu_blocks - fsp.fsu_bavail) * 100 / fsp.fsu_blocks;
disk_result = check_disk (usp, fsp.fsu_bavail);
result = max_state (disk_result, result);
- asprintf (&output, "%s %llu of %llu kB (%2.0f%%) free (%d-byte blocks) on %s (%s) %d\n",
+ asprintf (&output, "%s %llu of %llu MB (%2.0f%%) free on %s\n",
output,
- fsp.fsu_bavail*fsp.fsu_blocksize/1024,
- fsp.fsu_blocks*fsp.fsu_blocksize/1024,
+ fsp.fsu_bavail*fsp.fsu_blocksize/1024/1024,
+ fsp.fsu_blocks*fsp.fsu_blocksize/1024/1024,
(double)fsp.fsu_bavail*100/fsp.fsu_blocks,
- fsp.fsu_blocksize,
- me->me_mountdir,
- me->me_type, usp);
+ display_mntp ? me->me_devname : me->me_mountdir);
}
- }
+ }
terminate (result, "DISK %s %s\n", state_text (result), output);
}
process_arguments (int argc, char **argv)
{
int c;
+ struct name_list *se;
+ struct name_list **pathtail = &path_select_list;
+ struct name_list **devtail = &dev_select_list;
int option_index = 0;
static struct option long_options[] = {
{"errors-only", no_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{"mountpoint", no_argument, 0, 'm'},
+ {"device", no_argument, 0, 'd'},
{"exclude_device", required_argument, 0, 'x'},
{"quiet", no_argument, 0, 'q'},
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "+?Vqhvet:c:w:p:x:m", long_options, &option_index);
+ c = getopt_long (argc, argv, "+?Vqhvet:c:w:p:d:x:m", long_options, &option_index);
if (c == -1 || c == EOF)
break;
usage ("Timeout Interval must be an integer!\n");
}
case 'p': /* path or partition */
- path = optarg;
+ se = (struct name_list *) malloc (sizeof (struct name_list));
+ se->name = strdup (optarg);
+ *pathtail = se;
+ pathtail = &se->name_next;
+ break;
+ case 'd': /* path or partition */
+ se = (struct name_list *) malloc (sizeof (struct name_list));
+ se->name = strdup (optarg);
+ *devtail = se;
+ devtail = &se->name_next;
break;
case 'v': /* verbose */
verbose++;