Explorar o código

Display usage if no argv (Reuben Farrelly)

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1106 f882894a-f735-0410-b71e-b25c423dba1c
Stanley Hopcroft %!s(int64=21) %!d(string=hai) anos
pai
achega
3af1430c72
Modificáronse 1 ficheiros con 10 adicións e 6 borrados
  1. 10 6
      plugins/check_ide_smart.c

+ 10 - 6
plugins/check_ide_smart.c

@@ -181,11 +181,14 @@ main (int argc, char *argv[])
 	while (1) {
 	while (1) {
 		
 		
 		o = getopt_long (argc, argv, "+d:iq10nhV", longopts, &longindex);
 		o = getopt_long (argc, argv, "+d:iq10nhV", longopts, &longindex);
-		
-		if (o == -1 || o == EOF)
-			break;
 
 
 		switch (o) {
 		switch (o) {
+		case -1: 
+								/* 
+								 * bail out of the switch but not the loop, so
+								 * that device can be extracted from argv.
+								 */
+			break;
 		case 'd':
 		case 'd':
 			device = optarg;
 			device = optarg;
 			break;
 			break;
@@ -226,7 +229,7 @@ main (int argc, char *argv[])
 		fd = open (device, O_RDONLY);
 		fd = open (device, O_RDONLY);
 
 
 		if (fd < 0) {
 		if (fd < 0) {
-			printf (_("CRITICAL - Couldn't open device: %s\n"), strerror (errno));
+			printf (_("CRITICAL - Couldn't open device %s: %s\n"), device, strerror (errno));
 			return 2;
 			return 2;
 		}
 		}
 
 
@@ -498,12 +501,13 @@ print_help (void)
 	printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n");
 	printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n");
 	printf (COPYRIGHT, copyright, email);
 	printf (COPYRIGHT, copyright, email);
 
 
-	printf(_("This plugin checks this host's IDE hard drive through the (Linux specific) SMART command interface.\n\n"));
+	printf(_("This plugin checks a local hard drive with the (Linux specific) SMART interface [http://smartlinux.sourceforge.net/smart/index.php].\n\n"));
 	
 	
 	printf ("\
 	printf ("\
-Usage: %s [DEVICE] [OPTION]\n\
+Usage: %s [OPTION] [DEVICE]\n\
  -d, --device=DEVICE\n\
  -d, --device=DEVICE\n\
     Select device DEVICE\n\
     Select device DEVICE\n\
+    Note: if the device is selected with this option, _no_ other options are accepted\n\
  -i, --immediate\n\
  -i, --immediate\n\
     Perform immediately offline tests\n\
     Perform immediately offline tests\n\
  -q, --quiet-check\n\
  -q, --quiet-check\n\