[Nagiosplug-checkins] CVS: nagiosplug/plugins check_disk.c,1.1.1.1,1.2

Subhendu Ghosh sghosh at users.sourceforge.net
Wed Jun 5 21:16:03 CEST 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv30419

Modified Files:
	check_disk.c 
Log Message:
added option for mount point - Tom Bertelson

Index: check_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_disk.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_disk.c	28 Feb 2002 06:42:57 -0000	1.1.1.1
--- check_disk.c	6 Jun 2002 04:15:49 -0000	1.2
***************
*** 52,55 ****
--- 52,56 ----
  char *path = NULL;
  int verbose = FALSE;
+ int display_mntp = FALSE;
  
  int
***************
*** 65,68 ****
--- 66,70 ----
  	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;
***************
*** 93,105 ****
  
  		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) {
  			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);
  			outbuf[len] = 0;
  			output = strscat (output, outbuf);
--- 95,108 ----
  
  		if (sscanf
! 				(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,
! 									display_mntp ? mntp : file_system);
  			outbuf[len] = 0;
  			output = strscat (output, outbuf);
***************
*** 122,127 ****
  		result = max (result, STATE_WARNING);
  
! 	else if (usp < 0)
! 		printf ("Disk %s not mounted or nonexistant\n", argv[3]);
  	else if (result == STATE_UNKNOWN)
  		printf ("Unable to read output\n%s\n%s\n", command_line, input_buffer);
--- 125,130 ----
  		result = max (result, STATE_WARNING);
  
! 	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);
***************
*** 184,187 ****
--- 187,191 ----
  		{"version", no_argument, 0, 'V'},
  		{"help", no_argument, 0, 'h'},
+ 		{"mountpoint", no_argument, 0, 'm'},
  		{0, 0, 0, 0}
  	};
***************
*** 191,197 ****
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "+?Vhvt:c:w:p:", long_options, &option_index);
  #else
! 		c = getopt (argc, argv, "+?Vhvt:c:w:p:");
  #endif
  
--- 195,201 ----
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "+?Vhvt:c:w:p:m", long_options, &option_index);
  #else
! 		c = getopt (argc, argv, "+?Vhvt:c:w:p:m");
  #endif
  
***************
*** 256,259 ****
--- 260,266 ----
  			verbose = TRUE;
  			break;
+ 		case 'm': /* display mountpoint */
+ 			display_mntp = TRUE;
+ 			break;
  		case 'V':									/* version */
  			print_revision (my_basename (argv[0]), "$Revision$");
***************
*** 336,339 ****
--- 343,348 ----
  		 " -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"
***************
*** 348,352 ****
  {
  	printf
! 		("Usage: %s -w limit -c limit [-p path] [-t timeout] [--verbose]\n"
  		 "       %s (-h|--help)\n"
  		 "       %s (-V|--version)\n", PROGNAME, PROGNAME, PROGNAME);
--- 357,361 ----
  {
  	printf
! 		("Usage: %s -w limit -c limit [-p path] [-t timeout] [-m] [--verbose]\n"
  		 "       %s (-h|--help)\n"
  		 "       %s (-V|--version)\n", PROGNAME, PROGNAME, PROGNAME);





More information about the Commits mailing list