diff options
author | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2005-02-02 05:44:26 +0000 |
---|---|---|
committer | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2005-02-02 05:44:26 +0000 |
commit | b0eda8844333f509d5543fdec70415b0e26a1c86 (patch) | |
tree | 872e2d67abce97945dd640b75aba466579951f84 /plugins/check_ide_smart.c | |
parent | dcb13d4750e4416fc28017806d657ef24f67cc47 (diff) | |
download | monitoring-plugins-b0eda8844333f509d5543fdec70415b0e26a1c86.tar.gz |
restructure main() to stop looping on -n
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1126 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ide_smart.c')
-rw-r--r-- | plugins/check_ide_smart.c | 93 |
1 files changed, 48 insertions, 45 deletions
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 3156d271..bf123556 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c @@ -216,56 +216,56 @@ main (int argc, char *argv[]) default: usage2 (_("Unknown argument"), optarg); } + } - if (optind < argc) { - device = argv[optind]; - } + if (optind < argc) { + device = argv[optind]; + } - if (!device) { - print_help (); - return -1; - } + if (!device) { + print_help (); + return STATE_OK; + } - fd = open (device, O_RDONLY); + fd = open (device, O_RDONLY); - if (fd < 0) { - printf (_("CRITICAL - Couldn't open device %s: %s\n"), device, strerror (errno)); - return 2; - } + if (fd < 0) { + printf (_("CRITICAL - Couldn't open device %s: %s\n"), device, strerror (errno)); + return STATE_CRITICAL; + } - if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) { - printf (_("CRITICAL - SMART_CMD_ENABLE\n")); - return 2; - } + if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) { + 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; - } - close (fd); + 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; } + close (fd); return retval; } @@ -370,6 +370,7 @@ nagios (values_t * p, thresholds_t * t) prefailure > 1 ? 's' : ' ', failed, total); + status=STATE_CRITICAL; break; case ADVISORY: printf (_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"), @@ -377,14 +378,16 @@ nagios (values_t * p, thresholds_t * t) advisory > 1 ? "ies" : "y", failed, total); + status=STATE_WARNING; break; case OPERATIONAL: printf (_("OK - Operational (%d/%d tests passed)\n"), passed, total); + status=STATE_OK; break; default: - printf (_("ERROR - Status '%d' uknown. %d/%d tests passed\n"), status, + printf (_("ERROR - Status '%d' unkown. %d/%d tests passed\n"), status, passed, total); - status = -1; + status = STATE_UNKNOWN; break; } return status; |