summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dcb13d4)
raw | patch | inline | side by side (parent: dcb13d4)
author | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | |
Wed, 2 Feb 2005 05:44:26 +0000 (05:44 +0000) | ||
committer | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | |
Wed, 2 Feb 2005 05:44:26 +0000 (05:44 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1126 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_ide_smart.c | patch | blob | history |
index 3156d2719c3fe8caf6f282380fa4831af0d85d41..bf123556d54159e733137c9ee1af21204aa38e8e 100644 (file)
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;
}
prefailure > 1 ? 's' : ' ',
failed,
total);
+ status=STATE_CRITICAL;
break;
case ADVISORY:
printf (_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"),
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;