diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_ide_smart.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index bce1f31..c348cb7 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c | |||
@@ -172,6 +172,7 @@ void print_value (value_t *, threshold_t *); | |||
172 | void print_values (values_t *, thresholds_t *); | 172 | void print_values (values_t *, thresholds_t *); |
173 | int smart_cmd_simple (int, enum SmartCommand, __u8, char); | 173 | int smart_cmd_simple (int, enum SmartCommand, __u8, char); |
174 | int smart_read_thresholds (int, thresholds_t *); | 174 | int smart_read_thresholds (int, thresholds_t *); |
175 | int verbose = FALSE; | ||
175 | 176 | ||
176 | int | 177 | int |
177 | main (int argc, char *argv[]) | 178 | main (int argc, char *argv[]) |
@@ -191,7 +192,7 @@ main (int argc, char *argv[]) | |||
191 | {"quiet-check", no_argument, 0, 'q'}, | 192 | {"quiet-check", no_argument, 0, 'q'}, |
192 | {"auto-on", no_argument, 0, '1'}, | 193 | {"auto-on", no_argument, 0, '1'}, |
193 | {"auto-off", no_argument, 0, '0'}, | 194 | {"auto-off", no_argument, 0, '0'}, |
194 | {"nagios", no_argument, 0, 'n'}, | 195 | {"nagios", no_argument, 0, 'n'}, /* DEPRECATED, but we still accept it */ |
195 | {"help", no_argument, 0, 'h'}, | 196 | {"help", no_argument, 0, 'h'}, |
196 | {"version", no_argument, 0, 'V'}, | 197 | {"version", no_argument, 0, 'V'}, |
197 | {0, 0, 0, 0} | 198 | {0, 0, 0, 0} |
@@ -206,7 +207,7 @@ main (int argc, char *argv[]) | |||
206 | 207 | ||
207 | while (1) { | 208 | while (1) { |
208 | 209 | ||
209 | o = getopt_long (argc, argv, "+d:iq10nhV", longopts, &longindex); | 210 | o = getopt_long (argc, argv, "+d:iq10nhVv", longopts, &longindex); |
210 | 211 | ||
211 | if (o == -1 || o == EOF || o == 1) | 212 | if (o == -1 || o == EOF || o == 1) |
212 | break; | 213 | break; |
@@ -216,7 +217,8 @@ main (int argc, char *argv[]) | |||
216 | device = optarg; | 217 | device = optarg; |
217 | break; | 218 | break; |
218 | case 'q': | 219 | case 'q': |
219 | command = 3; | 220 | fprintf (stderr, "%s\n", _("DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\".")); |
221 | fprintf (stderr, "%s\n", _("Nagios-compatible output is now always returned.")); | ||
220 | break; | 222 | break; |
221 | case 'i': | 223 | case 'i': |
222 | command = 2; | 224 | command = 2; |
@@ -228,7 +230,11 @@ main (int argc, char *argv[]) | |||
228 | command = 0; | 230 | command = 0; |
229 | break; | 231 | break; |
230 | case 'n': | 232 | case 'n': |
231 | command = 4; | 233 | fprintf (stderr, "%s\n", _("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the")); |
234 | fprintf (stderr, "%s\n", _("default and will be removed from future releases.")); | ||
235 | break; | ||
236 | case 'v': /* verbose */ | ||
237 | verbose = TRUE; | ||
232 | break; | 238 | break; |
233 | case 'h': | 239 | case 'h': |
234 | print_help (); | 240 | print_help (); |
@@ -257,7 +263,7 @@ main (int argc, char *argv[]) | |||
257 | return STATE_CRITICAL; | 263 | return STATE_CRITICAL; |
258 | } | 264 | } |
259 | 265 | ||
260 | if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) { | 266 | if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, FALSE)) { |
261 | printf (_("CRITICAL - SMART_CMD_ENABLE\n")); | 267 | printf (_("CRITICAL - SMART_CMD_ENABLE\n")); |
262 | return STATE_CRITICAL; | 268 | return STATE_CRITICAL; |
263 | } | 269 | } |
@@ -272,20 +278,11 @@ main (int argc, char *argv[]) | |||
272 | case 2: | 278 | case 2: |
273 | retval = smart_cmd_simple (fd, SMART_CMD_IMMEDIATE_OFFLINE, 0, TRUE); | 279 | retval = smart_cmd_simple (fd, SMART_CMD_IMMEDIATE_OFFLINE, 0, TRUE); |
274 | break; | 280 | break; |
275 | case 3: | ||
276 | smart_read_values (fd, &values); | ||
277 | smart_read_thresholds (fd, &thresholds); | ||
278 | retval = values_not_passed (&values, &thresholds); | ||
279 | break; | ||
280 | case 4: | ||
281 | smart_read_values (fd, &values); | ||
282 | smart_read_thresholds (fd, &thresholds); | ||
283 | retval = nagios (&values, &thresholds); | ||
284 | break; | ||
285 | default: | 281 | default: |
286 | smart_read_values (fd, &values); | 282 | smart_read_values (fd, &values); |
287 | smart_read_thresholds (fd, &thresholds); | 283 | smart_read_thresholds (fd, &thresholds); |
288 | print_values (&values, &thresholds); | 284 | retval = nagios (&values, &thresholds); |
285 | if (verbose) print_values (&values, &thresholds); | ||
289 | break; | 286 | break; |
290 | } | 287 | } |
291 | close (fd); | 288 | close (fd); |
@@ -495,7 +492,7 @@ print_values (values_t * p, thresholds_t * t) | |||
495 | int | 492 | int |
496 | smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error) | 493 | smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error) |
497 | { | 494 | { |
498 | int e = 0; | 495 | int e = STATE_UNKNOWN; |
499 | #ifdef __linux__ | 496 | #ifdef __linux__ |
500 | __u8 args[4]; | 497 | __u8 args[4]; |
501 | args[0] = WIN_SMART; | 498 | args[0] = WIN_SMART; |
@@ -503,11 +500,15 @@ smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error) | |||
503 | args[2] = smart_command[command].value; | 500 | args[2] = smart_command[command].value; |
504 | args[3] = 0; | 501 | args[3] = 0; |
505 | if (ioctl (fd, HDIO_DRIVE_CMD, &args)) { | 502 | if (ioctl (fd, HDIO_DRIVE_CMD, &args)) { |
506 | e = errno; | 503 | e = STATE_CRITICAL; |
507 | if (show_error) { | 504 | if (show_error) |
508 | printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno)); | 505 | printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno)); |
509 | } | 506 | } else { |
507 | e = STATE_OK; | ||
508 | if (show_error) | ||
509 | printf (_("OK - Command sent (%s)\n"), smart_command[command].text); | ||
510 | } | 510 | } |
511 | |||
511 | #endif /* __linux__ */ | 512 | #endif /* __linux__ */ |
512 | #ifdef __NetBSD__ | 513 | #ifdef __NetBSD__ |
513 | struct atareq req; | 514 | struct atareq req; |
@@ -528,10 +529,15 @@ smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error) | |||
528 | } | 529 | } |
529 | 530 | ||
530 | if (errno != 0) { | 531 | if (errno != 0) { |
531 | e = errno; | 532 | e = STATE_CRITICAL; |
532 | printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno)); | 533 | if (show_error) |
533 | return e; | 534 | printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno)); |
535 | } else { | ||
536 | e = STATE_OK; | ||
537 | if (show_error) | ||
538 | printf (_("OK - Command sent (%s)\n"), smart_command[command].text); | ||
534 | } | 539 | } |
540 | |||
535 | #endif /* __NetBSD__ */ | 541 | #endif /* __NetBSD__ */ |
536 | return e; | 542 | return e; |
537 | } | 543 | } |
@@ -592,8 +598,8 @@ print_help (void) | |||
592 | { | 598 | { |
593 | print_revision (progname, NP_VERSION); | 599 | print_revision (progname, NP_VERSION); |
594 | 600 | ||
595 | printf ("monitoring feature - 1999 Robert Dale <rdale@digital-mission.com>\n"); | ||
596 | printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n"); | 601 | printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n"); |
602 | printf ("Plugin implementation - 1999 Robert Dale <rdale@digital-mission.com>\n"); | ||
597 | printf (COPYRIGHT, copyright, email); | 603 | printf (COPYRIGHT, copyright, email); |
598 | 604 | ||
599 | printf (_("This plugin checks a local hard drive with the (Linux specific) SMART interface [http://smartlinux.sourceforge.net/smart/index.php].")); | 605 | printf (_("This plugin checks a local hard drive with the (Linux specific) SMART interface [http://smartlinux.sourceforge.net/smart/index.php].")); |
@@ -616,9 +622,8 @@ print_help (void) | |||
616 | printf (" %s\n", _("Turn on automatic offline tests")); | 622 | printf (" %s\n", _("Turn on automatic offline tests")); |
617 | printf (" %s\n", "-0, --auto-off"); | 623 | printf (" %s\n", "-0, --auto-off"); |
618 | printf (" %s\n", _("Turn off automatic offline tests")); | 624 | printf (" %s\n", _("Turn off automatic offline tests")); |
619 | printf (" %s\n", "-n, --monitoring"); | ||
620 | printf (" %s\n", _("Output suitable for the monitoring system")); | ||
621 | 625 | ||
626 | printf (UT_VERBOSE); | ||
622 | printf (UT_SUPPORT); | 627 | printf (UT_SUPPORT); |
623 | } | 628 | } |
624 | 629 | ||
@@ -638,6 +643,6 @@ void | |||
638 | print_usage (void) | 643 | print_usage (void) |
639 | { | 644 | { |
640 | printf ("%s\n", _("Usage:")); | 645 | printf ("%s\n", _("Usage:")); |
641 | printf ("%s [-d <device>] [-i <immediate>] [-q quiet] [-1 <auto-on>]",progname); | 646 | printf ("%s [-d <device>] [-i <immediate>] [-q quiet] [-1 <auto-on>]", progname); |
642 | printf (" [-O <auto-off>] [-n <nagios>]\n"); | 647 | printf (" [-O <auto-off>] [-v]\n"); |
643 | } | 648 | } |