summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_ide_smart.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c
index 3156d27..bf12355 100644
--- a/plugins/check_ide_smart.c
+++ b/plugins/check_ide_smart.c
@@ -216,56 +216,56 @@ main (int argc, char *argv[])
216 default: 216 default:
217 usage2 (_("Unknown argument"), optarg); 217 usage2 (_("Unknown argument"), optarg);
218 } 218 }
219 }
219 220
220 if (optind < argc) { 221 if (optind < argc) {
221 device = argv[optind]; 222 device = argv[optind];
222 } 223 }
223 224
224 if (!device) { 225 if (!device) {
225 print_help (); 226 print_help ();
226 return -1; 227 return STATE_OK;
227 } 228 }
228 229
229 fd = open (device, O_RDONLY); 230 fd = open (device, O_RDONLY);
230 231
231 if (fd < 0) { 232 if (fd < 0) {
232 printf (_("CRITICAL - Couldn't open device %s: %s\n"), device, strerror (errno)); 233 printf (_("CRITICAL - Couldn't open device %s: %s\n"), device, strerror (errno));
233 return 2; 234 return STATE_CRITICAL;
234 } 235 }
235 236
236 if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) { 237 if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) {
237 printf (_("CRITICAL - SMART_CMD_ENABLE\n")); 238 printf (_("CRITICAL - SMART_CMD_ENABLE\n"));
238 return 2; 239 return STATE_CRITICAL;
239 } 240 }
240 241
241 switch (command) { 242 switch (command) {
242 case 0: 243 case 0:
243 retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0, TRUE); 244 retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0, TRUE);
244 break; 245 break;
245 case 1: 246 case 1:
246 retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0xF8, TRUE); 247 retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0xF8, TRUE);
247 break; 248 break;
248 case 2: 249 case 2:
249 retval = smart_cmd_simple (fd, SMART_CMD_IMMEDIATE_OFFLINE, 0, TRUE); 250 retval = smart_cmd_simple (fd, SMART_CMD_IMMEDIATE_OFFLINE, 0, TRUE);
250 break; 251 break;
251 case 3: 252 case 3:
252 smart_read_values (fd, &values); 253 smart_read_values (fd, &values);
253 smart_read_thresholds (fd, &thresholds); 254 smart_read_thresholds (fd, &thresholds);
254 retval = values_not_passed (&values, &thresholds); 255 retval = values_not_passed (&values, &thresholds);
255 break; 256 break;
256 case 4: 257 case 4:
257 smart_read_values (fd, &values); 258 smart_read_values (fd, &values);
258 smart_read_thresholds (fd, &thresholds); 259 smart_read_thresholds (fd, &thresholds);
259 retval = nagios (&values, &thresholds); 260 retval = nagios (&values, &thresholds);
260 break; 261 break;
261 default: 262 default:
262 smart_read_values (fd, &values); 263 smart_read_values (fd, &values);
263 smart_read_thresholds (fd, &thresholds); 264 smart_read_thresholds (fd, &thresholds);
264 print_values (&values, &thresholds); 265 print_values (&values, &thresholds);
265 break; 266 break;
266 }
267 close (fd);
268 } 267 }
268 close (fd);
269 return retval; 269 return retval;
270} 270}
271 271
@@ -370,6 +370,7 @@ nagios (values_t * p, thresholds_t * t)
370 prefailure > 1 ? 's' : ' ', 370 prefailure > 1 ? 's' : ' ',
371 failed, 371 failed,
372 total); 372 total);
373 status=STATE_CRITICAL;
373 break; 374 break;
374 case ADVISORY: 375 case ADVISORY:
375 printf (_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"), 376 printf (_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"),
@@ -377,14 +378,16 @@ nagios (values_t * p, thresholds_t * t)
377 advisory > 1 ? "ies" : "y", 378 advisory > 1 ? "ies" : "y",
378 failed, 379 failed,
379 total); 380 total);
381 status=STATE_WARNING;
380 break; 382 break;
381 case OPERATIONAL: 383 case OPERATIONAL:
382 printf (_("OK - Operational (%d/%d tests passed)\n"), passed, total); 384 printf (_("OK - Operational (%d/%d tests passed)\n"), passed, total);
385 status=STATE_OK;
383 break; 386 break;
384 default: 387 default:
385 printf (_("ERROR - Status '%d' uknown. %d/%d tests passed\n"), status, 388 printf (_("ERROR - Status '%d' unkown. %d/%d tests passed\n"), status,
386 passed, total); 389 passed, total);
387 status = -1; 390 status = STATE_UNKNOWN;
388 break; 391 break;
389 } 392 }
390 return status; 393 return status;