summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33d91ab)
raw | patch | inline | side by side (parent: 33d91ab)
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Thu, 6 Jun 2002 04:15:49 +0000 (04:15 +0000) | ||
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Thu, 6 Jun 2002 04:15:49 +0000 (04:15 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@46 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 d7aad072d61a8e2fdfb9bf92b44f13998b548912..742942496e80adaa059939a6b87c49d37e945805 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
float c_dfp = -1.0;
char *path = NULL;
int verbose = FALSE;
+int display_mntp = FALSE;
int
main (int argc, char **argv)
char *command_line = NULL;
char input_buffer[MAX_INPUT_BUFFER] = "";
char file_system[MAX_INPUT_BUFFER] = "";
+ char mntp[MAX_INPUT_BUFFER] = "";
char outbuf[MAX_INPUT_BUFFER] = "";
char *output = NULL;
continue;
if (sscanf
- (input_buffer, "%s %d %d %d %d%%", file_system, &total_disk,
- &used_disk, &free_disk, &usp) == 5
- || sscanf (input_buffer, "%s %*s %d %d %d %d%%", file_system,
- &total_disk, &used_disk, &free_disk, &usp) == 5) {
+ (input_buffer, "%s %d %d %d %d%% %s", file_system, &total_disk,
+ &used_disk, &free_disk, &usp, &mntp) == 6
+ || sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system,
+ &total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) {
+
result = max (result, check_disk (usp, free_disk));
len =
snprintf (outbuf, MAX_INPUT_BUFFER - 1,
" [%d kB (%d%%) free on %s]", free_disk, 100 - usp,
- file_system);
+ display_mntp ? mntp : file_system);
outbuf[len] = 0;
output = strscat (output, outbuf);
}
if (spclose (child_process))
result = max (result, STATE_WARNING);
- else if (usp < 0)
- printf ("Disk %s not mounted or nonexistant\n", argv[3]);
+ if (usp < 0)
+ printf ("Disk \"%s\" not mounted or nonexistant\n", path);
else if (result == STATE_UNKNOWN)
printf ("Unable to read output\n%s\n%s\n", command_line, input_buffer);
else
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
+ {"mountpoint", no_argument, 0, 'm'},
{0, 0, 0, 0}
};
#endif
while (1) {
#ifdef HAVE_GETOPT_H
c =
- getopt_long (argc, argv, "+?Vhvt:c:w:p:", long_options, &option_index);
+ getopt_long (argc, argv, "+?Vhvt:c:w:p:m", long_options, &option_index);
#else
- c = getopt (argc, argv, "+?Vhvt:c:w:p:");
+ c = getopt (argc, argv, "+?Vhvt:c:w:p:m");
#endif
i++;
case 'v': /* verbose */
verbose = TRUE;
break;
+ case 'm': /* display mountpoint */
+ display_mntp = TRUE;
+ break;
case 'V': /* version */
print_revision (my_basename (argv[0]), "$Revision$");
exit (STATE_OK);
" Exit with CRITCAL status if more than PERCENT of disk space is free\n"
" -p, --path=PATH, --partition=PARTTION\n"
" Path or partition (checks all mounted partitions if unspecified)\n"
+ " -m, --mountpoint\n"
+ " Display the mountpoint instead of the partition\n"
" -v, --verbose\n"
" Show details for command-line debugging (do not use with nagios server)\n"
" -h, --help\n"
print_usage (void)
{
printf
- ("Usage: %s -w limit -c limit [-p path] [-t timeout] [--verbose]\n"
+ ("Usage: %s -w limit -c limit [-p path] [-t timeout] [-m] [--verbose]\n"
" %s (-h|--help)\n"
" %s (-V|--version)\n", PROGNAME, PROGNAME, PROGNAME);
}