[monitoring-plugins] Disable SMART test commands in check_ide_smart

Git Repository git at monitoring-plugins.org
Thu Jan 23 09:30:07 CET 2014


 Module: monitoring-plugins
 Branch: master
 Commit: d080c3ad9772c9d5ec64802f377d924ea8cd0a28
 Author: Thomas Guyot-Sionnest <dermoth at aei.ca>
   Date: Thu Jan 23 03:17:55 2014 -0500
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=d080c3a

Disable SMART test commands in check_ide_smart

check_ide_smart could disable offline auto tests but could not re-enable
them. For this reason all SMART command modes have been disabled

The disabled commands are -0/--auto-off, -1/--auto-on and
-i/--immediate

---

 NEWS                      |  8 +++++--
 plugins/check_ide_smart.c | 55 +++++++++++++++++------------------------------
 2 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/NEWS b/NEWS
index 0cdcec7..23f1fa7 100644
--- a/NEWS
+++ b/NEWS
@@ -6,12 +6,16 @@ This file documents the major additions and syntax changes between releases.
 
 	FIXES
 	Don't let e.g. check_http's -C option reset SSL version if e.g. -S 1 -C 5 is specified
+	check_ide_smart could disable offline auto tests but could not re-enable them.
+	  For this reason all SMART command modes have been disabled.
 
 	WARNINGS
 	check_procs now ignores its parent process to avoid unexpected results when invoked via certain shells
-	utils.sh no longer defines ECHO
-	check_ide_smart -q (quiet) and -n (Nagios-compatile output) are now deprecated
+	utils.sh no longer defines ECH
+	check_ide_smart -q/--quiet and -n/--nagios (Nagios-compatile output) are now deprecated
 	  but accepted for backward-compatibility
+	check_ide_smart -0/--auto-off, -1/--auto-on and -i/--immediate: options have
+	  been disabled because they were broken
 
 1.5 2nd October 2013
 	ENHANCEMENTS
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c
index c348cb7..4eea72c 100644
--- a/plugins/check_ide_smart.c
+++ b/plugins/check_ide_smart.c
@@ -178,7 +178,6 @@ int
 main (int argc, char *argv[]) 
 {
 	char *device = NULL;
-	int command = -1;
 	int o, longindex;
 	int retval = 0;
 
@@ -221,13 +220,10 @@ main (int argc, char *argv[])
 			fprintf (stderr, "%s\n", _("Nagios-compatible output is now always returned."));
 			break;
 		case 'i':
-			command = 2;
-			break;
 		case '1':
-			command = 1;
-			break;
 		case '0':
-			command = 0;
+			printf ("%s\n", _("SMART commands are broken and have been disabled (See Notes in --help)."));
+			return STATE_CRITICAL;
 			break;
 		case 'n':
 			fprintf (stderr, "%s\n", _("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"));
@@ -268,23 +264,11 @@ main (int argc, char *argv[])
 		return STATE_CRITICAL;
 	}
 
-	switch (command) {
-	case 0:
-		retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0, TRUE);
-		break;
-	case 1:
-		retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0xF8, TRUE);
-		break;
-	case 2:
-		retval = smart_cmd_simple (fd, SMART_CMD_IMMEDIATE_OFFLINE, 0, TRUE);
-		break;
-	default:
-		smart_read_values (fd, &values);
-		smart_read_thresholds (fd, &thresholds);
-		retval = nagios (&values, &thresholds);
-		if (verbose) print_values (&values, &thresholds);
-		break;
-	}
+	smart_read_values (fd, &values);
+	smart_read_thresholds (fd, &thresholds);
+	retval = nagios (&values, &thresholds);
+	if (verbose) print_values (&values, &thresholds);
+
 	close (fd);
 	return retval;
 }
@@ -614,16 +598,18 @@ print_help (void)
   printf (" %s\n", "-d, --device=DEVICE");
   printf ("    %s\n", _("Select device DEVICE"));
   printf ("    %s\n", _("Note: if the device is selected with this option, _no_ other options are accepted"));
-  printf (" %s\n", "-i, --immediate");
-  printf ("    %s\n", _("Perform immediately offline tests"));
-  printf (" %s\n", "-q, --quiet-check");
-  printf ("    %s\n", _("Returns the number of failed tests"));
-  printf (" %s\n", "-1, --auto-on");
-  printf ("    %s\n", _("Turn on automatic offline tests"));
-  printf (" %s\n", "-0, --auto-off");
-  printf ("    %s\n", _("Turn off automatic offline tests"));
-
-	printf (UT_VERBOSE);
+
+  printf (UT_VERBOSE);
+
+  printf ("\n");
+  printf ("%s\n", _("Notes:"));
+  printf (" %s\n", _("The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"));
+  printf (" %s\n", _("broken in an underhand manner and have been disabled. You can use smartctl"));
+  printf (" %s\n", _("instead:"));
+  printf ("  %s\n", _("-0/--auto-off:  use \"smartctl --offlineauto=off\""));
+  printf ("  %s\n", _("-1/--auto-on:   use \"smartctl --offlineauto=on\""));
+  printf ("  %s\n", _("-i/--immediate: use \"smartctl --test=offline\""));
+
   printf (UT_SUPPORT);
 }
 
@@ -643,6 +629,5 @@ void
 print_usage (void)
 {
   printf ("%s\n", _("Usage:"));
-  printf ("%s [-d <device>] [-i <immediate>] [-q quiet] [-1 <auto-on>]", progname);
-  printf (" [-O <auto-off>] [-v]\n");
+  printf ("%s [-d <device>] [-v]", progname);
 }



More information about the Commits mailing list