Imported Upstream version 2.0
This commit is contained in:
parent
c89ccc3c74
commit
0841b5c7c7
165 changed files with 25440 additions and 4442 deletions
|
@ -1,13 +1,13 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* Nagios check_ide_smart plugin
|
||||
* Monitoring check_ide_smart plugin
|
||||
* ide-smart 1.3 - IDE S.M.A.R.T. checking tool
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (C) 1998-1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>
|
||||
* 1998 Gadi Oxman <gadio@netvision.net.il>
|
||||
* Copyright (c) 2000 Robert Dale <rdale@digital-mission.com>
|
||||
* Copyright (c) 2000-2007 Nagios Plugins Development Team
|
||||
* Copyright (c) 2000-2007 Monitoring Plugins Development Team
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
const char *progname = "check_ide_smart";
|
||||
const char *copyright = "1998-2007";
|
||||
const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
||||
const char *email = "devel@monitoring-plugins.org";
|
||||
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
@ -172,12 +172,12 @@ void print_value (value_t *, threshold_t *);
|
|||
void print_values (values_t *, thresholds_t *);
|
||||
int smart_cmd_simple (int, enum SmartCommand, __u8, char);
|
||||
int smart_read_thresholds (int, thresholds_t *);
|
||||
int verbose = FALSE;
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char *device = NULL;
|
||||
int command = -1;
|
||||
int o, longindex;
|
||||
int retval = 0;
|
||||
|
||||
|
@ -191,7 +191,7 @@ main (int argc, char *argv[])
|
|||
{"quiet-check", no_argument, 0, 'q'},
|
||||
{"auto-on", no_argument, 0, '1'},
|
||||
{"auto-off", no_argument, 0, '0'},
|
||||
{"nagios", no_argument, 0, 'n'},
|
||||
{"nagios", no_argument, 0, 'n'}, /* DEPRECATED, but we still accept it */
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{0, 0, 0, 0}
|
||||
|
@ -206,7 +206,7 @@ main (int argc, char *argv[])
|
|||
|
||||
while (1) {
|
||||
|
||||
o = getopt_long (argc, argv, "+d:iq10nhV", longopts, &longindex);
|
||||
o = getopt_long (argc, argv, "+d:iq10nhVv", longopts, &longindex);
|
||||
|
||||
if (o == -1 || o == EOF || o == 1)
|
||||
break;
|
||||
|
@ -216,19 +216,21 @@ main (int argc, char *argv[])
|
|||
device = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
command = 3;
|
||||
fprintf (stderr, "%s\n", _("DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."));
|
||||
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':
|
||||
command = 4;
|
||||
fprintf (stderr, "%s\n", _("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"));
|
||||
fprintf (stderr, "%s\n", _("default and will be removed from future releases."));
|
||||
break;
|
||||
case 'v': /* verbose */
|
||||
verbose = TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
print_help ();
|
||||
|
@ -257,37 +259,16 @@ main (int argc, char *argv[])
|
|||
return STATE_CRITICAL;
|
||||
}
|
||||
|
||||
if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) {
|
||||
if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, FALSE)) {
|
||||
printf (_("CRITICAL - SMART_CMD_ENABLE\n"));
|
||||
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;
|
||||
case 3:
|
||||
smart_read_values (fd, &values);
|
||||
smart_read_thresholds (fd, &thresholds);
|
||||
retval = values_not_passed (&values, &thresholds);
|
||||
break;
|
||||
case 4:
|
||||
smart_read_values (fd, &values);
|
||||
smart_read_thresholds (fd, &thresholds);
|
||||
retval = nagios (&values, &thresholds);
|
||||
break;
|
||||
default:
|
||||
smart_read_values (fd, &values);
|
||||
smart_read_thresholds (fd, &thresholds);
|
||||
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;
|
||||
}
|
||||
|
@ -368,7 +349,7 @@ values_not_passed (values_t * p, thresholds_t * t)
|
|||
int i;
|
||||
for (i = 0; i < NR_ATTRIBUTES; i++) {
|
||||
if (value->id && threshold->id && value->id == threshold->id) {
|
||||
if (value->value <= threshold->threshold) {
|
||||
if (value->value < threshold->threshold) {
|
||||
++failed;
|
||||
}
|
||||
else {
|
||||
|
@ -397,7 +378,7 @@ nagios (values_t * p, thresholds_t * t)
|
|||
int i;
|
||||
for (i = 0; i < NR_ATTRIBUTES; i++) {
|
||||
if (value->id && threshold->id && value->id == threshold->id) {
|
||||
if (value->value <= threshold->threshold) {
|
||||
if (value->value < threshold->threshold) {
|
||||
++failed;
|
||||
if (value->status & 1) {
|
||||
status = PREFAILURE;
|
||||
|
@ -438,7 +419,7 @@ nagios (values_t * p, thresholds_t * t)
|
|||
status=STATE_OK;
|
||||
break;
|
||||
default:
|
||||
printf (_("ERROR - Status '%d' unkown. %d/%d tests passed\n"), status,
|
||||
printf (_("ERROR - Status '%d' unknown. %d/%d tests passed\n"), status,
|
||||
passed, total);
|
||||
status = STATE_UNKNOWN;
|
||||
break;
|
||||
|
@ -454,7 +435,7 @@ print_value (value_t * p, threshold_t * t)
|
|||
printf ("Id=%3d, Status=%2d {%s , %s}, Value=%3d, Threshold=%3d, %s\n",
|
||||
p->id, p->status, p->status & 1 ? "PreFailure" : "Advisory ",
|
||||
p->status & 2 ? "OnLine " : "OffLine", p->value, t->threshold,
|
||||
p->value > t->threshold ? "Passed" : "Failed");
|
||||
p->value >= t->threshold ? "Passed" : "Failed");
|
||||
}
|
||||
|
||||
|
||||
|
@ -495,7 +476,7 @@ print_values (values_t * p, thresholds_t * t)
|
|||
int
|
||||
smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error)
|
||||
{
|
||||
int e = 0;
|
||||
int e = STATE_UNKNOWN;
|
||||
#ifdef __linux__
|
||||
__u8 args[4];
|
||||
args[0] = WIN_SMART;
|
||||
|
@ -503,11 +484,15 @@ smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error)
|
|||
args[2] = smart_command[command].value;
|
||||
args[3] = 0;
|
||||
if (ioctl (fd, HDIO_DRIVE_CMD, &args)) {
|
||||
e = errno;
|
||||
if (show_error) {
|
||||
e = STATE_CRITICAL;
|
||||
if (show_error)
|
||||
printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno));
|
||||
}
|
||||
} else {
|
||||
e = STATE_OK;
|
||||
if (show_error)
|
||||
printf (_("OK - Command sent (%s)\n"), smart_command[command].text);
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
#ifdef __NetBSD__
|
||||
struct atareq req;
|
||||
|
@ -528,10 +513,15 @@ smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error)
|
|||
}
|
||||
|
||||
if (errno != 0) {
|
||||
e = errno;
|
||||
printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno));
|
||||
return e;
|
||||
e = STATE_CRITICAL;
|
||||
if (show_error)
|
||||
printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno));
|
||||
} else {
|
||||
e = STATE_OK;
|
||||
if (show_error)
|
||||
printf (_("OK - Command sent (%s)\n"), smart_command[command].text);
|
||||
}
|
||||
|
||||
#endif /* __NetBSD__ */
|
||||
return e;
|
||||
}
|
||||
|
@ -592,8 +582,8 @@ print_help (void)
|
|||
{
|
||||
print_revision (progname, NP_VERSION);
|
||||
|
||||
printf ("Nagios feature - 1999 Robert Dale <rdale@digital-mission.com>\n");
|
||||
printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n");
|
||||
printf ("Plugin implementation - 1999 Robert Dale <rdale@digital-mission.com>\n");
|
||||
printf (COPYRIGHT, copyright, email);
|
||||
|
||||
printf (_("This plugin checks a local hard drive with the (Linux specific) SMART interface [http://smartlinux.sourceforge.net/smart/index.php]."));
|
||||
|
@ -607,17 +597,19 @@ 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 (" %s\n", "-n, --nagios");
|
||||
printf (" %s\n", _("Output suitable for Nagios"));
|
||||
printf (" %s\n", _("Note: if the device is specified without this option, any further option will"));
|
||||
printf (" %s\n", _("be ignored."));
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -638,6 +630,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>] [-n <nagios>]\n");
|
||||
printf ("%s [-d <device>] [-v]", progname);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue