diff options
author | Benoit Mortier <opensides@users.sourceforge.net> | 2004-12-01 23:54:51 +0000 |
---|---|---|
committer | Benoit Mortier <opensides@users.sourceforge.net> | 2004-12-01 23:54:51 +0000 |
commit | d19edd4043c498626fe68308005947975ef0a697 (patch) | |
tree | 7a213ee16f9331e928b1c32aa6c521c05519db58 /plugins/check_ide-smart.c | |
parent | 1d8128e328f714258b7fec0c62245e1d187e0439 (diff) | |
download | monitoring-plugins-d19edd4043c498626fe68308005947975ef0a697.tar.gz |
standardize localization string
standardize unknow arguments
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@969 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ide-smart.c')
-rw-r--r-- | plugins/check_ide-smart.c | 52 |
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 | |||
140 | char * | 144 | char * |
141 | get_offline_text (int status) | 145 | get_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 | |||
152 | int | 158 | int |
153 | smart_read_values (int fd, values_t * values) | 159 | smart_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 | |||
170 | int | 178 | int |
171 | values_not_passed (values_t * p, thresholds_t * t) | 179 | values_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 | |||
193 | int | 203 | int |
194 | net_saint (values_t * p, thresholds_t * t) | 204 | net_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 | |||
253 | void | 265 | void |
254 | print_value (value_t * p, threshold_t * t) | 266 | print_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 | |||
262 | void | 276 | void |
263 | print_values (values_t * p, thresholds_t * t) | 277 | print_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 | |||
294 | void | 310 | void |
295 | print_thresholds (thresholds_t * p) | 311 | print_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 | |||
329 | int | 347 | int |
330 | smart_read_thresholds (int fd, thresholds_t * thresholds) | 348 | smart_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 | |||
347 | void | 367 | void |
348 | show_version () | 368 | show_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 | |||
355 | void | 377 | void |
356 | show_help () | 378 | show_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 | |||
376 | int | 400 | int |
377 | main (int argc, char *argv[]) | 401 | main (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 | |||