diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 0e23c53..78e17b0 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c | |||
@@ -1,5 +1,14 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | 2 | ||
3 | check_ups | ||
4 | |||
5 | Program: Network UPS Tools plugin for Nagios | ||
6 | License: GPL | ||
7 | Copyright (c) 2000 Tom Shields | ||
8 | 2004 Alain Richard <alain.richard@equation.fr> | ||
9 | 2004 Arnaud Quette <arnaud.quette@mgeups.com> | ||
10 | |||
11 | |||
3 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
4 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
5 | the Free Software Foundation; either version 2 of the License, or (at | 14 | the Free Software Foundation; either version 2 of the License, or (at |
@@ -23,6 +32,7 @@ const char *revision = "$Revision$"; | |||
23 | const char *copyright = "2000-2002"; | 32 | const char *copyright = "2000-2002"; |
24 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 33 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
25 | 34 | ||
35 | #include <locale.h> | ||
26 | #include "common.h" | 36 | #include "common.h" |
27 | #include "netutils.h" | 37 | #include "netutils.h" |
28 | #include "utils.h" | 38 | #include "utils.h" |
@@ -40,14 +50,22 @@ enum { | |||
40 | #define UPS_TEMP 8 /* supports UPS temperature */ | 50 | #define UPS_TEMP 8 /* supports UPS temperature */ |
41 | #define UPS_LOADPCT 16 /* supports load percent */ | 51 | #define UPS_LOADPCT 16 /* supports load percent */ |
42 | 52 | ||
43 | #define UPSSTATUS_NONE 0 | 53 | #define UPSSTATUS_NONE 0 |
44 | #define UPSSTATUS_OFF 1 | 54 | #define UPSSTATUS_OFF 1 |
45 | #define UPSSTATUS_OL 2 | 55 | #define UPSSTATUS_OL 2 |
46 | #define UPSSTATUS_OB 4 | 56 | #define UPSSTATUS_OB 4 |
47 | #define UPSSTATUS_LB 8 | 57 | #define UPSSTATUS_LB 8 |
48 | #define UPSSTATUS_CAL 16 | 58 | #define UPSSTATUS_CAL 16 |
49 | #define UPSSTATUS_RB 32 /*Replace Battery */ | 59 | #define UPSSTATUS_RB 32 /*Replace Battery */ |
50 | #define UPSSTATUS_UNKOWN 64 | 60 | #define UPSSTATUS_BYPASS 64 |
61 | #define UPSSTATUS_OVER 128 | ||
62 | #define UPSSTATUS_TRIM 256 | ||
63 | #define UPSSTATUS_BOOST 512 | ||
64 | #define UPSSTATUS_CHRG 1024 | ||
65 | #define UPSSTATUS_DISCHRG 2048 | ||
66 | #define UPSSTATUS_UNKOWN 4096 | ||
67 | |||
68 | enum { NOSUCHVAR = ERROR-1 }; | ||
51 | 69 | ||
52 | int server_port = PORT; | 70 | int server_port = PORT; |
53 | char *server_address; | 71 | char *server_address; |
@@ -65,9 +83,9 @@ double ups_battery_percent = 0.0; | |||
65 | double ups_load_percent = 0.0; | 83 | double ups_load_percent = 0.0; |
66 | double ups_temperature = 0.0; | 84 | double ups_temperature = 0.0; |
67 | char *ups_status; | 85 | char *ups_status; |
86 | int temp_output_c = 0; | ||
68 | 87 | ||
69 | int determine_status (void); | 88 | int determine_status (void); |
70 | int determine_supported_vars (void); | ||
71 | int get_ups_variable (const char *, char *, size_t); | 89 | int get_ups_variable (const char *, char *, size_t); |
72 | 90 | ||
73 | int process_arguments (int, char **); | 91 | int process_arguments (int, char **); |
@@ -83,6 +101,7 @@ main (int argc, char **argv) | |||
83 | char *data; | 101 | char *data; |
84 | char temp_buffer[MAX_INPUT_BUFFER]; | 102 | char temp_buffer[MAX_INPUT_BUFFER]; |
85 | double ups_utility_deviation = 0.0; | 103 | double ups_utility_deviation = 0.0; |
104 | int res; | ||
86 | 105 | ||
87 | setlocale (LC_ALL, ""); | 106 | setlocale (LC_ALL, ""); |
88 | bindtextdomain (PACKAGE, LOCALEDIR); | 107 | bindtextdomain (PACKAGE, LOCALEDIR); |
@@ -90,6 +109,7 @@ main (int argc, char **argv) | |||
90 | 109 | ||
91 | ups_status = strdup ("N/A"); | 110 | ups_status = strdup ("N/A"); |
92 | data = strdup (""); | 111 | data = strdup (""); |
112 | message = strdup (""); | ||
93 | 113 | ||
94 | if (process_arguments (argc, argv) != OK) | 114 | if (process_arguments (argc, argv) != OK) |
95 | usage (_("check_ups: could not parse arguments\n")); | 115 | usage (_("check_ups: could not parse arguments\n")); |
@@ -100,15 +120,11 @@ main (int argc, char **argv) | |||
100 | /* set socket timeout */ | 120 | /* set socket timeout */ |
101 | alarm (socket_timeout); | 121 | alarm (socket_timeout); |
102 | 122 | ||
103 | /* determine what variables the UPS supports */ | ||
104 | if (determine_supported_vars () != OK) | ||
105 | return STATE_CRITICAL; | ||
106 | |||
107 | /* get the ups status if possible */ | 123 | /* get the ups status if possible */ |
124 | if (determine_status () != OK) | ||
125 | return STATE_CRITICAL; | ||
108 | if (supported_options & UPS_STATUS) { | 126 | if (supported_options & UPS_STATUS) { |
109 | 127 | ||
110 | if (determine_status () != OK) | ||
111 | return STATE_CRITICAL; | ||
112 | ups_status = strdup (""); | 128 | ups_status = strdup (""); |
113 | result = STATE_OK; | 129 | result = STATE_OK; |
114 | 130 | ||
@@ -140,6 +156,24 @@ main (int argc, char **argv) | |||
140 | asprintf (&ups_status, "%s%s", ups_status, ", Replace Battery"); | 156 | asprintf (&ups_status, "%s%s", ups_status, ", Replace Battery"); |
141 | result = STATE_WARNING; | 157 | result = STATE_WARNING; |
142 | } | 158 | } |
159 | if (status & UPSSTATUS_BYPASS) { | ||
160 | asprintf (&ups_status, "%s%s", ups_status, ", On Bypass"); | ||
161 | } | ||
162 | if (status & UPSSTATUS_OVER) { | ||
163 | asprintf (&ups_status, "%s%s", ups_status, ", Overload"); | ||
164 | } | ||
165 | if (status & UPSSTATUS_TRIM) { | ||
166 | asprintf (&ups_status, "%s%s", ups_status, ", Trimming"); | ||
167 | } | ||
168 | if (status & UPSSTATUS_BOOST) { | ||
169 | asprintf (&ups_status, "%s%s", ups_status, ", Boosting"); | ||
170 | } | ||
171 | if (status & UPSSTATUS_CHRG) { | ||
172 | asprintf (&ups_status, "%s%s", ups_status, ", Charging"); | ||
173 | } | ||
174 | if (status & UPSSTATUS_DISCHRG) { | ||
175 | asprintf (&ups_status, "%s%s", ups_status, ", Discharging"); | ||
176 | } | ||
143 | if (status & UPSSTATUS_UNKOWN) { | 177 | if (status & UPSSTATUS_UNKOWN) { |
144 | asprintf (&ups_status, "%s%s", ups_status, ", Unknown"); | 178 | asprintf (&ups_status, "%s%s", ups_status, ", Unknown"); |
145 | } | 179 | } |
@@ -148,10 +182,12 @@ main (int argc, char **argv) | |||
148 | } | 182 | } |
149 | 183 | ||
150 | /* get the ups utility voltage if possible */ | 184 | /* get the ups utility voltage if possible */ |
151 | if (supported_options & UPS_UTILITY) { | 185 | res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer)); |
152 | 186 | if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY; | |
153 | if (get_ups_variable ("UTILITY", temp_buffer, sizeof (temp_buffer)) != OK) | 187 | else if (res != OK) |
154 | return STATE_CRITICAL; | 188 | return STATE_CRITICAL; |
189 | else { | ||
190 | supported_options |= UPS_UTILITY; | ||
155 | 191 | ||
156 | ups_utility_voltage = atof (temp_buffer); | 192 | ups_utility_voltage = atof (temp_buffer); |
157 | asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage); | 193 | asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage); |
@@ -169,23 +205,24 @@ main (int argc, char **argv) | |||
169 | result = max_state (result, STATE_WARNING); | 205 | result = max_state (result, STATE_WARNING); |
170 | } | 206 | } |
171 | asprintf (&data, "%s", | 207 | asprintf (&data, "%s", |
172 | fperfdata ("voltage", ups_utility_voltage, "V", | 208 | perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", |
173 | check_warn, warning_value, | 209 | check_warn, (long)(1000*warning_value), |
174 | check_crit, critical_value, | 210 | check_crit, (long)(1000*critical_value), |
175 | TRUE, 0, FALSE, 0)); | 211 | TRUE, 0, FALSE, 0)); |
176 | } else { | 212 | } else { |
177 | asprintf (&data, "%s", | 213 | asprintf (&data, "%s", |
178 | fperfdata ("voltage", ups_utility_voltage, "V", | 214 | perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", |
179 | FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); | 215 | FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); |
180 | } | 216 | } |
181 | } | 217 | } |
182 | 218 | ||
183 | /* get the ups battery percent if possible */ | 219 | /* get the ups battery percent if possible */ |
184 | if (supported_options & UPS_BATTPCT) { | 220 | res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer)); |
185 | 221 | if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT; | |
186 | if (get_ups_variable ("BATTPCT", temp_buffer, sizeof (temp_buffer)) != OK) | 222 | else if ( res != OK) |
187 | return STATE_CRITICAL; | 223 | return STATE_CRITICAL; |
188 | 224 | else { | |
225 | supported_options |= UPS_BATTPCT; | ||
189 | ups_battery_percent = atof (temp_buffer); | 226 | ups_battery_percent = atof (temp_buffer); |
190 | asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent); | 227 | asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent); |
191 | 228 | ||
@@ -209,11 +246,12 @@ main (int argc, char **argv) | |||
209 | } | 246 | } |
210 | 247 | ||
211 | /* get the ups load percent if possible */ | 248 | /* get the ups load percent if possible */ |
212 | if (supported_options & UPS_LOADPCT) { | 249 | res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer)); |
213 | 250 | if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT; | |
214 | if (get_ups_variable ("LOADPCT", temp_buffer, sizeof (temp_buffer)) != OK) | 251 | else if ( res != OK) |
215 | return STATE_CRITICAL; | 252 | return STATE_CRITICAL; |
216 | 253 | else { | |
254 | supported_options |= UPS_LOADPCT; | ||
217 | ups_load_percent = atof (temp_buffer); | 255 | ups_load_percent = atof (temp_buffer); |
218 | asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent); | 256 | asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent); |
219 | 257 | ||
@@ -237,13 +275,20 @@ main (int argc, char **argv) | |||
237 | } | 275 | } |
238 | 276 | ||
239 | /* get the ups temperature if possible */ | 277 | /* get the ups temperature if possible */ |
240 | if (supported_options & UPS_TEMP) { | 278 | res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer)); |
241 | 279 | if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP; | |
242 | if (get_ups_variable ("UPSTEMP", temp_buffer, sizeof (temp_buffer)) != OK) | 280 | else if ( res != OK) |
243 | return STATE_CRITICAL; | 281 | return STATE_CRITICAL; |
244 | 282 | else { | |
245 | ups_temperature = (atof (temp_buffer) * 1.8) + 32; | 283 | supported_options |= UPS_TEMP; |
246 | asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); | 284 | if (temp_output_c) { |
285 | ups_temperature = atof (temp_buffer); | ||
286 | asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature); | ||
287 | } | ||
288 | else { | ||
289 | ups_temperature = (atof (temp_buffer) * 1.8) + 32; | ||
290 | asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); | ||
291 | } | ||
247 | 292 | ||
248 | if (check_variable == UPS_TEMP) { | 293 | if (check_variable == UPS_TEMP) { |
249 | if (check_crit==TRUE && ups_temperature>=critical_value) { | 294 | if (check_crit==TRUE && ups_temperature>=critical_value) { |
@@ -286,14 +331,16 @@ determine_status (void) | |||
286 | char recv_buffer[MAX_INPUT_BUFFER]; | 331 | char recv_buffer[MAX_INPUT_BUFFER]; |
287 | char temp_buffer[MAX_INPUT_BUFFER]; | 332 | char temp_buffer[MAX_INPUT_BUFFER]; |
288 | char *ptr; | 333 | char *ptr; |
334 | int res; | ||
289 | 335 | ||
290 | if (get_ups_variable ("STATUS", recv_buffer, sizeof (recv_buffer)) != | 336 | res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); |
291 | STATE_OK) { | 337 | if (res == NOSUCHVAR) return OK; |
338 | if (res != STATE_OK) { | ||
292 | printf ("Invalid response received from host\n"); | 339 | printf ("Invalid response received from host\n"); |
293 | return ERROR; | 340 | return ERROR; |
294 | } | 341 | } |
295 | 342 | ||
296 | recv_buffer[strlen (recv_buffer) - 1] = 0; | 343 | supported_options |= UPS_STATUS; |
297 | 344 | ||
298 | strcpy (temp_buffer, recv_buffer); | 345 | strcpy (temp_buffer, recv_buffer); |
299 | for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; | 346 | for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; |
@@ -310,6 +357,18 @@ determine_status (void) | |||
310 | status |= UPSSTATUS_CAL; | 357 | status |= UPSSTATUS_CAL; |
311 | else if (!strcmp (ptr, "RB")) | 358 | else if (!strcmp (ptr, "RB")) |
312 | status |= UPSSTATUS_RB; | 359 | status |= UPSSTATUS_RB; |
360 | else if (!strcmp (ptr, "BYPASS")) | ||
361 | status |= UPSSTATUS_BYPASS; | ||
362 | else if (!strcmp (ptr, "OVER")) | ||
363 | status |= UPSSTATUS_OVER; | ||
364 | else if (!strcmp (ptr, "TRIM")) | ||
365 | status |= UPSSTATUS_TRIM; | ||
366 | else if (!strcmp (ptr, "BOOST")) | ||
367 | status |= UPSSTATUS_BOOST; | ||
368 | else if (!strcmp (ptr, "CHRG")) | ||
369 | status |= UPSSTATUS_CHRG; | ||
370 | else if (!strcmp (ptr, "DISCHRG")) | ||
371 | status |= UPSSTATUS_DISCHRG; | ||
313 | else | 372 | else |
314 | status |= UPSSTATUS_UNKOWN; | 373 | status |= UPSSTATUS_UNKOWN; |
315 | } | 374 | } |
@@ -318,55 +377,6 @@ determine_status (void) | |||
318 | } | 377 | } |
319 | 378 | ||
320 | 379 | ||
321 | /* determines what options are supported by the UPS */ | ||
322 | int | ||
323 | determine_supported_vars (void) | ||
324 | { | ||
325 | char send_buffer[MAX_INPUT_BUFFER]; | ||
326 | char recv_buffer[MAX_INPUT_BUFFER]; | ||
327 | char temp_buffer[MAX_INPUT_BUFFER]; | ||
328 | char *ptr; | ||
329 | |||
330 | |||
331 | /* get the list of variables that this UPS supports */ | ||
332 | if (ups_name) | ||
333 | sprintf (send_buffer, "LISTVARS %s\r\n", ups_name); | ||
334 | else | ||
335 | sprintf (send_buffer, "LISTVARS\r\n"); | ||
336 | if (process_tcp_request | ||
337 | (server_address, server_port, send_buffer, recv_buffer, | ||
338 | sizeof (recv_buffer)) != STATE_OK) { | ||
339 | printf ("Invalid response received from host\n"); | ||
340 | return ERROR; | ||
341 | } | ||
342 | |||
343 | recv_buffer[strlen (recv_buffer) - 1] = 0; | ||
344 | |||
345 | if (ups_name) | ||
346 | ptr = recv_buffer + 5 + strlen (ups_name) + 2; | ||
347 | else | ||
348 | ptr = recv_buffer + 5; | ||
349 | |||
350 | strcpy (temp_buffer, recv_buffer); | ||
351 | |||
352 | for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; | ||
353 | ptr = (char *) strtok (NULL, " ")) { | ||
354 | if (!strcmp (ptr, "UTILITY")) | ||
355 | supported_options |= UPS_UTILITY; | ||
356 | else if (!strcmp (ptr, "BATTPCT")) | ||
357 | supported_options |= UPS_BATTPCT; | ||
358 | else if (!strcmp (ptr, "LOADPCT")) | ||
359 | supported_options |= UPS_LOADPCT; | ||
360 | else if (!strcmp (ptr, "STATUS")) | ||
361 | supported_options |= UPS_STATUS; | ||
362 | else if (!strcmp (ptr, "UPSTEMP")) | ||
363 | supported_options |= UPS_TEMP; | ||
364 | } | ||
365 | |||
366 | return OK; | ||
367 | } | ||
368 | |||
369 | |||
370 | /* gets a variable value for a specific UPS */ | 380 | /* gets a variable value for a specific UPS */ |
371 | int | 381 | int |
372 | get_ups_variable (const char *varname, char *buf, size_t buflen) | 382 | get_ups_variable (const char *varname, char *buf, size_t buflen) |
@@ -375,12 +385,12 @@ get_ups_variable (const char *varname, char *buf, size_t buflen) | |||
375 | char temp_buffer[MAX_INPUT_BUFFER]; | 385 | char temp_buffer[MAX_INPUT_BUFFER]; |
376 | char send_buffer[MAX_INPUT_BUFFER]; | 386 | char send_buffer[MAX_INPUT_BUFFER]; |
377 | char *ptr; | 387 | char *ptr; |
388 | int len; | ||
378 | 389 | ||
390 | *buf=0; | ||
391 | |||
379 | /* create the command string to send to the UPS daemon */ | 392 | /* create the command string to send to the UPS daemon */ |
380 | if (ups_name) | 393 | sprintf (send_buffer, "GET VAR %s %s\n", ups_name, varname); |
381 | sprintf (send_buffer, "REQ %s@%s\n", varname, ups_name); | ||
382 | else | ||
383 | sprintf (send_buffer, "REQ %s\n", varname); | ||
384 | 394 | ||
385 | /* send the command to the daemon and get a response back */ | 395 | /* send the command to the daemon and get a response back */ |
386 | if (process_tcp_request | 396 | if (process_tcp_request |
@@ -390,38 +400,43 @@ get_ups_variable (const char *varname, char *buf, size_t buflen) | |||
390 | return ERROR; | 400 | return ERROR; |
391 | } | 401 | } |
392 | 402 | ||
393 | if (ups_name) | 403 | ptr = temp_buffer; |
394 | ptr = temp_buffer + strlen (varname) + 5 + strlen (ups_name) + 1; | 404 | len = strlen(ptr); |
395 | else | 405 | if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0; |
396 | ptr = temp_buffer + strlen (varname) + 5; | 406 | if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) { |
397 | 407 | printf ("CRITICAL - no such ups '%s' on that host\n", ups_name); | |
398 | if (!strcmp (ptr, "NOT-SUPPORTED")) { | ||
399 | printf ("CRITICAL - Variable '%s' is not supported\n", varname); | ||
400 | return ERROR; | 408 | return ERROR; |
401 | } | 409 | } |
402 | 410 | ||
403 | if (!strcmp (ptr, "DATA-STALE")) { | 411 | if (strcmp (ptr, "ERR VAR-NOT-SUPPORTED") == 0) { |
412 | //printf ("Error: Variable '%s' is not supported\n", varname); | ||
413 | return NOSUCHVAR; | ||
414 | } | ||
415 | |||
416 | if (strcmp (ptr, "ERR DATA-STALE") == 0) { | ||
404 | printf ("CRITICAL - UPS data is stale\n"); | 417 | printf ("CRITICAL - UPS data is stale\n"); |
405 | return ERROR; | 418 | return ERROR; |
406 | } | 419 | } |
407 | 420 | ||
408 | if (!strcmp (ptr, "UNKNOWN-UPS")) { | 421 | if (strncmp (ptr, "ERR", 3) == 0) { |
409 | if (ups_name) | 422 | printf ("Unknown error: %s\n", ptr); |
410 | printf ("CRITICAL - UPS '%s' is unknown\n", ups_name); | ||
411 | else | ||
412 | printf ("CRITICAL - UPS is unknown\n"); | ||
413 | return ERROR; | 423 | return ERROR; |
414 | } | 424 | } |
415 | 425 | ||
416 | strncpy (buf, ptr, buflen - 1); | 426 | ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6; |
417 | buf[buflen - 1] = 0; | 427 | len = strlen(ptr); |
428 | if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') { | ||
429 | printf ("Error: unable to parse variable\n"); | ||
430 | return ERROR; | ||
431 | } | ||
432 | strncpy (buf, ptr+1, len - 2); | ||
433 | buf[len - 2] = 0; | ||
418 | 434 | ||
419 | return OK; | 435 | return OK; |
420 | } | 436 | } |
421 | 437 | ||
422 | 438 | ||
423 | 439 | /* Command line: CHECK_UPS -H <host_address> -u ups [-p port] [-v variable] | |
424 | /* Command line: CHECK_UPS <host_address> [-u ups] [-p port] [-v variable] | ||
425 | [-wv warn_value] [-cv crit_value] [-to to_sec] */ | 440 | [-wv warn_value] [-cv crit_value] [-to to_sec] */ |
426 | 441 | ||
427 | 442 | ||
@@ -439,6 +454,7 @@ process_arguments (int argc, char **argv) | |||
439 | {"critical", required_argument, 0, 'c'}, | 454 | {"critical", required_argument, 0, 'c'}, |
440 | {"warning", required_argument, 0, 'w'}, | 455 | {"warning", required_argument, 0, 'w'}, |
441 | {"timeout", required_argument, 0, 't'}, | 456 | {"timeout", required_argument, 0, 't'}, |
457 | {"temperature", no_argument, 0, 'T'}, | ||
442 | {"variable", required_argument, 0, 'v'}, | 458 | {"variable", required_argument, 0, 'v'}, |
443 | {"version", no_argument, 0, 'V'}, | 459 | {"version", no_argument, 0, 'V'}, |
444 | {"help", no_argument, 0, 'h'}, | 460 | {"help", no_argument, 0, 'h'}, |
@@ -458,7 +474,7 @@ process_arguments (int argc, char **argv) | |||
458 | } | 474 | } |
459 | 475 | ||
460 | while (1) { | 476 | while (1) { |
461 | c = getopt_long (argc, argv, "hVH:u:p:v:c:w:t:", longopts, | 477 | c = getopt_long (argc, argv, "hVTH:u:p:v:c:w:t:", longopts, |
462 | &option); | 478 | &option); |
463 | 479 | ||
464 | if (c == -1 || c == EOF) | 480 | if (c == -1 || c == EOF) |
@@ -477,6 +493,9 @@ process_arguments (int argc, char **argv) | |||
477 | usage2 (_("Invalid hostname/address"), optarg); | 493 | usage2 (_("Invalid hostname/address"), optarg); |
478 | } | 494 | } |
479 | break; | 495 | break; |
496 | case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */ | ||
497 | temp_output_c = 1; | ||
498 | break; | ||
480 | case 'u': /* ups name */ | 499 | case 'u': /* ups name */ |
481 | ups_name = optarg; | 500 | ups_name = optarg; |
482 | break; | 501 | break; |
@@ -554,6 +573,10 @@ process_arguments (int argc, char **argv) | |||
554 | int | 573 | int |
555 | validate_arguments (void) | 574 | validate_arguments (void) |
556 | { | 575 | { |
576 | if (! ups_name) { | ||
577 | printf ("Error : no ups indicated\n"); | ||
578 | return ERROR; | ||
579 | } | ||
557 | return OK; | 580 | return OK; |
558 | } | 581 | } |
559 | 582 | ||
@@ -568,11 +591,14 @@ print_help (void) | |||
568 | print_revision (progname, revision); | 591 | print_revision (progname, revision); |
569 | 592 | ||
570 | printf ("Copyright (c) 2000 Tom Shields"); | 593 | printf ("Copyright (c) 2000 Tom Shields"); |
594 | printf ("Copyright (c) 2004 Alain Richard <alain.richard@equation.fr>\n"); | ||
595 | printf ("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n"); | ||
596 | |||
571 | printf (COPYRIGHT, copyright, email); | 597 | printf (COPYRIGHT, copyright, email); |
572 | 598 | ||
573 | printf (_("This plugin tests the UPS service on the specified host.\n\ | 599 | printf (_("This plugin tests the UPS service on the specified host.\n\ |
574 | Network UPS Tools from www.exploits.org must be running for this plugin to\n\ | 600 | Network UPS Tools from www.networkupstools.org must be running for this\n\ |
575 | work.\n\n")); | 601 | plugin to work.\n\n")); |
576 | 602 | ||
577 | print_usage (); | 603 | print_usage (); |
578 | 604 | ||
@@ -584,6 +610,10 @@ work.\n\n")); | |||
584 | -u, --ups=STRING\n\ | 610 | -u, --ups=STRING\n\ |
585 | Name of UPS\n")); | 611 | Name of UPS\n")); |
586 | 612 | ||
613 | printf (_("\ | ||
614 | -T, --temperature\n\ | ||
615 | Output of temperatures in Celsius\n")); | ||
616 | |||
587 | printf (_(UT_WARN_CRIT)); | 617 | printf (_(UT_WARN_CRIT)); |
588 | 618 | ||
589 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | 619 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); |
@@ -607,7 +637,7 @@ will have to use the [ups] option to specify which UPS to check.\n\n")); | |||
607 | This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ | 637 | This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ |
608 | Smart UPS Tools be installed on the remote host. If you do not have the\n\ | 638 | Smart UPS Tools be installed on the remote host. If you do not have the\n\ |
609 | package installed on your system, you can download it from\n\ | 639 | package installed on your system, you can download it from\n\ |
610 | http://www.exploits.org/nut\n\n")); | 640 | http://www.networkupstools.org\n\n")); |
611 | 641 | ||
612 | printf (_(UT_SUPPORT)); | 642 | printf (_(UT_SUPPORT)); |
613 | } | 643 | } |
@@ -618,7 +648,7 @@ void | |||
618 | print_usage (void) | 648 | print_usage (void) |
619 | { | 649 | { |
620 | printf (_("\ | 650 | printf (_("\ |
621 | Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ | 651 | Usage: %s -H host -u ups [-p port] [-v variable]\n\ |
622 | [-t timeout] [-v]\n"), progname); | 652 | [-wv warn_value] [-cv crit_value] [-to to_sec] [-T]\n"), progname); |
623 | printf (_(UT_HLP_VRS), progname, progname); | 653 | printf (_(UT_HLP_VRS), progname, progname); |
624 | } | 654 | } |