[Nagiosplug-checkins] CVS: nagiosplug/plugins check_disk.c,1.16,1.17
Karl DeBisschop
kdebisschop at users.sourceforge.net
Sat Mar 22 22:12:09 CET 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv3224/plugins
Modified Files:
check_disk.c
Log Message:
add -X to exclude FS type, now works with more than one path/dev specified
Index: check_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_disk.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** check_disk.c 21 Mar 2003 14:08:01 -0000 1.16
--- check_disk.c 23 Mar 2003 06:11:26 -0000 1.17
***************
*** 139,142 ****
--- 139,143 ----
int validate_arguments (void);
int check_disk (int usp, int free_disk);
+ int walk_name_list (struct name_list *list, const char *name);
void print_help (void);
void print_usage (void);
***************
*** 169,172 ****
--- 170,174 ----
char mntp[MAX_INPUT_BUFFER];
char *output = "";
+ char *details = "";
struct mount_entry *me;
***************
*** 182,191 ****
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);
--- 184,195 ----
if ((dev_select_list &&
! walk_name_list (dev_select_list, me->me_devname)) ||
(path_select_list &&
! walk_name_list (path_select_list, me->me_mountdir)))
get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
else if (dev_select_list || path_select_list)
continue;
+ else if (fs_exclude_list && walk_name_list (fs_exclude_list, me->me_type))
+ continue;
else
get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
***************
*** 195,211 ****
disk_result = check_disk (usp, fsp.fsu_bavail);
result = max_state (disk_result, result);
! asprintf (&output, "%s %llu of %llu MB (%2.0f%%) free on %s\n",
! output,
fsp.fsu_bavail*fsp.fsu_blocksize/1024/1024,
fsp.fsu_blocks*fsp.fsu_blocksize/1024/1024,
(double)fsp.fsu_bavail*100/fsp.fsu_blocks,
! display_mntp ? me->me_devname : me->me_mountdir);
}
}
! terminate (result, "DISK %s %s\n", state_text (result), output);
}
/* process command-line arguments */
int
--- 199,232 ----
disk_result = check_disk (usp, fsp.fsu_bavail);
result = max_state (disk_result, result);
! if (disk_result==STATE_OK && erronly && !verbose)
! continue;
!
! if (disk_result!=STATE_OK || verbose>=0)
! asprintf (&output, "%s [%llu MB (%2.0f%%) free on %s]",
! output,
! fsp.fsu_bavail*fsp.fsu_blocksize/1024/1024,
! (double)fsp.fsu_bavail*100/fsp.fsu_blocks,
! (!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
! asprintf (&details, "%s\n%llu of %llu MB (%2.0f%%) free on %s (type %s mounted on %s)",
! details,
fsp.fsu_bavail*fsp.fsu_blocksize/1024/1024,
fsp.fsu_blocks*fsp.fsu_blocksize/1024/1024,
(double)fsp.fsu_bavail*100/fsp.fsu_blocks,
! me->me_devname,
! me->me_type,
! me->me_mountdir);
}
}
! if (verbose > 2)
! asprintf (&output, "%s%s", output, details);
!
! terminate (result, "DISK %s%s\n", state_text (result), output, details);
}
+
+
+
/* process command-line arguments */
int
***************
*** 216,219 ****
--- 237,241 ----
struct name_list **pathtail = &path_select_list;
struct name_list **devtail = &dev_select_list;
+ struct name_list **fstail = &fs_exclude_list;
int option_index = 0;
***************
*** 244,248 ****
while (1) {
! c = getopt_long (argc, argv, "+?Vqhvet:c:w:p:d:x:m", long_options, &option_index);
if (c == -1 || c == EOF)
--- 266,270 ----
while (1) {
! c = getopt_long (argc, argv, "+?Vqhvet:c:w:p:d:x:X:m", long_options, &option_index);
if (c == -1 || c == EOF)
***************
*** 293,296 ****
--- 315,319 ----
se = (struct name_list *) malloc (sizeof (struct name_list));
se->name = strdup (optarg);
+ se->name_next = NULL;
*pathtail = se;
pathtail = &se->name_next;
***************
*** 299,305 ****
--- 322,336 ----
se = (struct name_list *) malloc (sizeof (struct name_list));
se->name = strdup (optarg);
+ se->name_next = NULL;
*devtail = se;
devtail = &se->name_next;
break;
+ case 'X': /* path or partition */
+ se = (struct name_list *) malloc (sizeof (struct name_list));
+ se->name = strdup (optarg);
+ se->name_next = NULL;
+ *fstail = se;
+ fstail = &se->name_next;
+ break;
case 'v': /* verbose */
verbose++;
***************
*** 342,345 ****
--- 373,378 ----
}
+
+
int
validate_arguments ()
***************
*** 368,373 ****
}
int
! check_disk (usp, free_disk)
{
int result = STATE_UNKNOWN;
--- 401,409 ----
}
+
+
+
int
! check_disk (int usp, int free_disk)
{
int result = STATE_UNKNOWN;
***************
*** 386,389 ****
--- 422,441 ----
}
+
+
+ int
+ walk_name_list (struct name_list *list, const char *name)
+ {
+ while (list) {
+ if (! strcmp(list->name, name))
+ return TRUE;
+ list = list->name_next;
+ }
+ return FALSE;
+ }
+
+
+
+
void
print_help (void)
More information about the Commits
mailing list