summaryrefslogtreecommitdiffstats
path: root/plugins/check_ide-smart.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_ide-smart.c')
-rw-r--r--plugins/check_ide-smart.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/plugins/check_ide-smart.c b/plugins/check_ide-smart.c
index 06deb12a..9d3c3160 100644
--- a/plugins/check_ide-smart.c
+++ b/plugins/check_ide-smart.c
@@ -2,7 +2,7 @@
2 * check_ide-smart v.1 - hacked version of ide-smart for Nagios 2 * check_ide-smart v.1 - hacked version of ide-smart for Nagios
3 * Copyright (C) 2000 Robert Dale <rdale@digital-mission.com> 3 * Copyright (C) 2000 Robert Dale <rdale@digital-mission.com>
4 * 4 *
5 * Net Saint - http://www.nagios.org 5 * Nagios - http://www.nagios.org
6 * 6 *
7 * Notes: 7 * Notes:
8 * ide-smart has the same functionality as before. Some return 8 * ide-smart has the same functionality as before. Some return
@@ -33,6 +33,8 @@
33 * You should have received a copy of the GNU General Public License 33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the Free Software 34 * along with this program; if not, write to the Free Software
35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 *
37 * $Id$
36 */ 38 */
37 39
38#include "common.h" 40#include "common.h"
@@ -137,6 +139,8 @@ enum SmartCommand
137 SMART_CMD_AUTO_OFFLINE 139 SMART_CMD_AUTO_OFFLINE
138 }; 140 };
139 141
142
143
140char * 144char *
141get_offline_text (int status) 145get_offline_text (int status)
142{ 146{
@@ -146,9 +150,11 @@ get_offline_text (int status)
146 return offline_status_text[i].text; 150 return offline_status_text[i].text;
147 } 151 }
148 } 152 }
149 return "unknown"; 153 return "UNKNOW";
150} 154}
151 155
156
157
152int 158int
153smart_read_values (int fd, values_t * values) 159smart_read_values (int fd, values_t * values)
154{ 160{
@@ -160,13 +166,15 @@ smart_read_values (int fd, values_t * values)
160 args[3] = 1; 166 args[3] = 1;
161 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) { 167 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) {
162 e = errno; 168 e = errno;
163 printf (_("CRITICAL: SMART_READ_VALUES: %s\n"), strerror (errno)); 169 printf (_("CRITICAL - SMART_READ_VALUES: %s\n"), strerror (errno));
164 return e; 170 return e;
165 } 171 }
166 memcpy (values, args + 4, 512); 172 memcpy (values, args + 4, 512);
167 return 0; 173 return 0;
168} 174}
169 175
176
177
170int 178int
171values_not_passed (values_t * p, thresholds_t * t) 179values_not_passed (values_t * p, thresholds_t * t)
172{ 180{
@@ -190,6 +198,8 @@ values_not_passed (values_t * p, thresholds_t * t)
190 return (passed ? -failed : 2); 198 return (passed ? -failed : 2);
191} 199}
192 200
201
202
193int 203int
194net_saint (values_t * p, thresholds_t * t) 204net_saint (values_t * p, thresholds_t * t)
195{ 205{
@@ -225,24 +235,24 @@ net_saint (values_t * p, thresholds_t * t)
225 } 235 }
226 switch (status) { 236 switch (status) {
227 case PREFAILURE: 237 case PREFAILURE:
228 printf (_("CRITICAL: %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"), 238 printf (_("CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"),
229 prefailure, 239 prefailure,
230 prefailure > 1 ? 's' : ' ', 240 prefailure > 1 ? 's' : ' ',
231 failed, 241 failed,
232 total); 242 total);
233 break; 243 break;
234 case ADVISORY: 244 case ADVISORY:
235 printf (_("WARNING: %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"), 245 printf (_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"),
236 advisory, 246 advisory,
237 advisory > 1 ? "ies" : "y", 247 advisory > 1 ? "ies" : "y",
238 failed, 248 failed,
239 total); 249 total);
240 break; 250 break;
241 case OPERATIONAL: 251 case OPERATIONAL:
242 printf (_("Status: Operational (%d/%d tests passed)\n"), passed, total); 252 printf (_("STATUS - Operational (%d/%d tests passed)\n"), passed, total);
243 break; 253 break;
244 default: 254 default:
245 printf (_("Error: Status '%d' uknown. %d/%d tests passed\n"), status, 255 printf (_("ERROR - Status '%d' uknown. %d/%d tests passed\n"), status,
246 passed, total); 256 passed, total);
247 status = -1; 257 status = -1;
248 break; 258 break;
@@ -250,6 +260,8 @@ net_saint (values_t * p, thresholds_t * t)
250 return status; 260 return status;
251} 261}
252 262
263
264
253void 265void
254print_value (value_t * p, threshold_t * t) 266print_value (value_t * p, threshold_t * t)
255{ 267{
@@ -259,6 +271,8 @@ print_value (value_t * p, threshold_t * t)
259 p->value > t->threshold ? "Passed" : "Failed"); 271 p->value > t->threshold ? "Passed" : "Failed");
260} 272}
261 273
274
275
262void 276void
263print_values (values_t * p, thresholds_t * t) 277print_values (values_t * p, thresholds_t * t)
264{ 278{
@@ -291,6 +305,8 @@ print_values (values_t * p, thresholds_t * t)
291 p->smart_capability & 2 ? "AutoSave" : ""); 305 p->smart_capability & 2 ? "AutoSave" : "");
292} 306}
293 307
308
309
294void 310void
295print_thresholds (thresholds_t * p) 311print_thresholds (thresholds_t * p)
296{ 312{
@@ -320,12 +336,14 @@ smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0,
320 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) { 336 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) {
321 e = errno; 337 e = errno;
322 if (show_error) { 338 if (show_error) {
323 printf (_("CRITICAL: %s: %s\n"), smart_command[command].text, strerror (errno)); 339 printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno));
324 } 340 }
325 } 341 }
326 return e; 342 return e;
327} 343}
328 344
345
346
329int 347int
330smart_read_thresholds (int fd, thresholds_t * thresholds) 348smart_read_thresholds (int fd, thresholds_t * thresholds)
331{ 349{
@@ -337,13 +355,15 @@ smart_read_thresholds (int fd, thresholds_t * thresholds)
337 args[3] = 1; 355 args[3] = 1;
338 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) { 356 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) {
339 e = errno; 357 e = errno;
340 printf (_("CRITICAL: SMART_READ_THRESHOLDS: %s\n"), strerror (errno)); 358 printf (_("CRITICAL - SMART_READ_THRESHOLDS: %s\n"), strerror (errno));
341 return e; 359 return e;
342 } 360 }
343 memcpy (thresholds, args + 4, 512); 361 memcpy (thresholds, args + 4, 512);
344 return 0; 362 return 0;
345} 363}
346 364
365
366
347void 367void
348show_version () 368show_version ()
349{ 369{
@@ -352,6 +372,8 @@ show_version ()
352 printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n"); 372 printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n");
353} 373}
354 374
375
376
355void 377void
356show_help () 378show_help ()
357{ 379{
@@ -373,6 +395,8 @@ Usage: check_ide-smart [DEVICE] [OPTION]\n\
373 -V, --version\n")); 395 -V, --version\n"));
374} 396}
375 397
398
399
376int 400int
377main (int argc, char *argv[]) 401main (int argc, char *argv[])
378{ 402{
@@ -433,8 +457,9 @@ main (int argc, char *argv[])
433 show_version (); 457 show_version ();
434 return 0; 458 return 0;
435 default: 459 default:
436 printf (_("Try `%s --help' for more information.\n"), argv[0]); 460 printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
437 return 1; 461 print_usage ();
462 exit (STATE_UNKNOWN);
438 } 463 }
439 464
440 if (optind < argc) { 465 if (optind < argc) {
@@ -450,12 +475,12 @@ main (int argc, char *argv[])
450 fd = open (device, O_RDONLY); 475 fd = open (device, O_RDONLY);
451 476
452 if (fd < 0) { 477 if (fd < 0) {
453 printf (_("CRITICAL: Couldn't open device: %s\n"), strerror (errno)); 478 printf (_("CRITICAL - Couldn't open device: %s\n"), strerror (errno));
454 return 2; 479 return 2;
455 } 480 }
456 481
457 if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) { 482 if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) {
458 printf (_("CRITICAL: SMART_CMD_ENABLE\n")); 483 printf (_("CRITICAL - SMART_CMD_ENABLE\n"));
459 return 2; 484 return 2;
460 } 485 }
461 486
@@ -489,4 +514,3 @@ main (int argc, char *argv[])
489 } 514 }
490 return retval; 515 return retval;
491} 516}
492