diff options
Diffstat (limited to 'plugins/check_ups.c')
-rw-r--r-- | plugins/check_ups.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 099881d..0de37a2 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c | |||
@@ -242,8 +242,8 @@ main (int argc, char **argv) | |||
242 | } | 242 | } |
243 | xasprintf (&data, "%s %s", data, | 243 | xasprintf (&data, "%s %s", data, |
244 | perfdata ("battery", (long)ups_battery_percent, "%", | 244 | perfdata ("battery", (long)ups_battery_percent, "%", |
245 | check_warn, (long)(1000*warning_value), | 245 | check_warn, (long)(warning_value), |
246 | check_crit, (long)(1000*critical_value), | 246 | check_crit, (long)(critical_value), |
247 | TRUE, 0, TRUE, 100)); | 247 | TRUE, 0, TRUE, 100)); |
248 | } else { | 248 | } else { |
249 | xasprintf (&data, "%s %s", data, | 249 | xasprintf (&data, "%s %s", data, |
@@ -271,8 +271,8 @@ main (int argc, char **argv) | |||
271 | } | 271 | } |
272 | xasprintf (&data, "%s %s", data, | 272 | xasprintf (&data, "%s %s", data, |
273 | perfdata ("load", (long)ups_load_percent, "%", | 273 | perfdata ("load", (long)ups_load_percent, "%", |
274 | check_warn, (long)(1000*warning_value), | 274 | check_warn, (long)(warning_value), |
275 | check_crit, (long)(1000*critical_value), | 275 | check_crit, (long)(critical_value), |
276 | TRUE, 0, TRUE, 100)); | 276 | TRUE, 0, TRUE, 100)); |
277 | } else { | 277 | } else { |
278 | xasprintf (&data, "%s %s", data, | 278 | xasprintf (&data, "%s %s", data, |
@@ -308,8 +308,8 @@ main (int argc, char **argv) | |||
308 | } | 308 | } |
309 | xasprintf (&data, "%s %s", data, | 309 | xasprintf (&data, "%s %s", data, |
310 | perfdata ("temp", (long)ups_temperature, tunits, | 310 | perfdata ("temp", (long)ups_temperature, tunits, |
311 | check_warn, (long)(1000*warning_value), | 311 | check_warn, (long)(warning_value), |
312 | check_crit, (long)(1000*critical_value), | 312 | check_crit, (long)(critical_value), |
313 | TRUE, 0, FALSE, 0)); | 313 | TRUE, 0, FALSE, 0)); |
314 | } else { | 314 | } else { |
315 | xasprintf (&data, "%s %s", data, | 315 | xasprintf (&data, "%s %s", data, |
@@ -402,7 +402,10 @@ get_ups_variable (const char *varname, char *buf, size_t buflen) | |||
402 | 402 | ||
403 | /* create the command string to send to the UPS daemon */ | 403 | /* create the command string to send to the UPS daemon */ |
404 | /* Add LOGOUT to avoid read failure logs */ | 404 | /* Add LOGOUT to avoid read failure logs */ |
405 | sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname); | 405 | if (snprintf (send_buffer, sizeof(send_buffer), "GET VAR %s %s\nLOGOUT\n", ups_name, varname) >= sizeof(send_buffer)) { |
406 | printf("%s\n", _("UPS name to long for buffer")); | ||
407 | return ERROR; | ||
408 | } | ||
406 | 409 | ||
407 | /* send the command to the daemon and get a response back */ | 410 | /* send the command to the daemon and get a response back */ |
408 | if (process_tcp_request | 411 | if (process_tcp_request |
@@ -558,10 +561,10 @@ process_arguments (int argc, char **argv) | |||
558 | break; | 561 | break; |
559 | case 'V': /* version */ | 562 | case 'V': /* version */ |
560 | print_revision (progname, NP_VERSION); | 563 | print_revision (progname, NP_VERSION); |
561 | exit (STATE_OK); | 564 | exit (STATE_UNKNOWN); |
562 | case 'h': /* help */ | 565 | case 'h': /* help */ |
563 | print_help (); | 566 | print_help (); |
564 | exit (STATE_OK); | 567 | exit (STATE_UNKNOWN); |
565 | } | 568 | } |
566 | } | 569 | } |
567 | 570 | ||