diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-25 09:45:58 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-25 09:45:58 (GMT) |
commit | 05ad606c09325ae9ae7d4607a55236245dcad47a (patch) | |
tree | 0e159442540465d1b6141728b7e10c0593cee69b /plugins | |
parent | 39705a8c1f7b8ecba29b1e3e5abb906d9c2e6b5b (diff) | |
download | monitoring-plugins-05ad606c09325ae9ae7d4607a55236245dcad47a.tar.gz |
check_ups: clang-format againrefs/pull/2030/head
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_ups.c | 144 |
1 files changed, 39 insertions, 105 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index c2451ab..f60c0e9 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c | |||
@@ -235,19 +235,9 @@ int main(int argc, char **argv) { | |||
235 | } else if (config.check_warn && ups_utility_deviation >= config.warning_value) { | 235 | } else if (config.check_warn && ups_utility_deviation >= config.warning_value) { |
236 | result = max_state(result, STATE_WARNING); | 236 | result = max_state(result, STATE_WARNING); |
237 | } | 237 | } |
238 | xasprintf(&data, | 238 | xasprintf(&data, "%s", |
239 | "%s", | 239 | perfdata("voltage", (long)(1000 * ups_utility_voltage), "mV", config.check_warn, (long)(1000 * config.warning_value), |
240 | perfdata("voltage", | 240 | config.check_crit, (long)(1000 * config.critical_value), true, 0, false, 0)); |
241 | (long)(1000 * ups_utility_voltage), | ||
242 | "mV", | ||
243 | config.check_warn, | ||
244 | (long)(1000 * config.warning_value), | ||
245 | config.check_crit, | ||
246 | (long)(1000 * config.critical_value), | ||
247 | true, | ||
248 | 0, | ||
249 | false, | ||
250 | 0)); | ||
251 | } else { | 241 | } else { |
252 | xasprintf(&data, "%s", perfdata("voltage", (long)(1000 * ups_utility_voltage), "mV", false, 0, false, 0, true, 0, false, 0)); | 242 | xasprintf(&data, "%s", perfdata("voltage", (long)(1000 * ups_utility_voltage), "mV", false, 0, false, 0, true, 0, false, 0)); |
253 | } | 243 | } |
@@ -272,20 +262,9 @@ int main(int argc, char **argv) { | |||
272 | } else if (config.check_warn && ups_battery_percent <= config.warning_value) { | 262 | } else if (config.check_warn && ups_battery_percent <= config.warning_value) { |
273 | result = max_state(result, STATE_WARNING); | 263 | result = max_state(result, STATE_WARNING); |
274 | } | 264 | } |
275 | xasprintf(&data, | 265 | xasprintf(&data, "%s %s", data, |
276 | "%s %s", | 266 | perfdata("battery", (long)ups_battery_percent, "%", config.check_warn, (long)(config.warning_value), |
277 | data, | 267 | config.check_crit, (long)(config.critical_value), true, 0, true, 100)); |
278 | perfdata("battery", | ||
279 | (long)ups_battery_percent, | ||
280 | "%", | ||
281 | config.check_warn, | ||
282 | (long)(config.warning_value), | ||
283 | config.check_crit, | ||
284 | (long)(config.critical_value), | ||
285 | true, | ||
286 | 0, | ||
287 | true, | ||
288 | 100)); | ||
289 | } else { | 268 | } else { |
290 | xasprintf(&data, "%s %s", data, perfdata("battery", (long)ups_battery_percent, "%", false, 0, false, 0, true, 0, true, 100)); | 269 | xasprintf(&data, "%s %s", data, perfdata("battery", (long)ups_battery_percent, "%", false, 0, false, 0, true, 0, true, 100)); |
291 | } | 270 | } |
@@ -310,20 +289,9 @@ int main(int argc, char **argv) { | |||
310 | } else if (config.check_warn && ups_load_percent >= config.warning_value) { | 289 | } else if (config.check_warn && ups_load_percent >= config.warning_value) { |
311 | result = max_state(result, STATE_WARNING); | 290 | result = max_state(result, STATE_WARNING); |
312 | } | 291 | } |
313 | xasprintf(&data, | 292 | xasprintf(&data, "%s %s", data, |
314 | "%s %s", | 293 | perfdata("load", (long)ups_load_percent, "%", config.check_warn, (long)(config.warning_value), config.check_crit, |
315 | data, | 294 | (long)(config.critical_value), true, 0, true, 100)); |
316 | perfdata("load", | ||
317 | (long)ups_load_percent, | ||
318 | "%", | ||
319 | config.check_warn, | ||
320 | (long)(config.warning_value), | ||
321 | config.check_crit, | ||
322 | (long)(config.critical_value), | ||
323 | true, | ||
324 | 0, | ||
325 | true, | ||
326 | 100)); | ||
327 | } else { | 295 | } else { |
328 | xasprintf(&data, "%s %s", data, perfdata("load", (long)ups_load_percent, "%", false, 0, false, 0, true, 0, true, 100)); | 296 | xasprintf(&data, "%s %s", data, perfdata("load", (long)ups_load_percent, "%", false, 0, false, 0, true, 0, true, 100)); |
329 | } | 297 | } |
@@ -357,20 +325,9 @@ int main(int argc, char **argv) { | |||
357 | } else if (config.check_warn && ups_temperature >= config.warning_value) { | 325 | } else if (config.check_warn && ups_temperature >= config.warning_value) { |
358 | result = max_state(result, STATE_WARNING); | 326 | result = max_state(result, STATE_WARNING); |
359 | } | 327 | } |
360 | xasprintf(&data, | 328 | xasprintf(&data, "%s %s", data, |
361 | "%s %s", | 329 | perfdata("temp", (long)ups_temperature, tunits, config.check_warn, (long)(config.warning_value), config.check_crit, |
362 | data, | 330 | (long)(config.critical_value), true, 0, false, 0)); |
363 | perfdata("temp", | ||
364 | (long)ups_temperature, | ||
365 | tunits, | ||
366 | config.check_warn, | ||
367 | (long)(config.warning_value), | ||
368 | config.check_crit, | ||
369 | (long)(config.critical_value), | ||
370 | true, | ||
371 | 0, | ||
372 | false, | ||
373 | 0)); | ||
374 | } else { | 331 | } else { |
375 | xasprintf(&data, "%s %s", data, perfdata("temp", (long)ups_temperature, tunits, false, 0, false, 0, true, 0, false, 0)); | 332 | xasprintf(&data, "%s %s", data, perfdata("temp", (long)ups_temperature, tunits, false, 0, false, 0, true, 0, false, 0)); |
376 | } | 333 | } |
@@ -394,20 +351,9 @@ int main(int argc, char **argv) { | |||
394 | } else if (config.check_warn && ups_realpower >= config.warning_value) { | 351 | } else if (config.check_warn && ups_realpower >= config.warning_value) { |
395 | result = max_state(result, STATE_WARNING); | 352 | result = max_state(result, STATE_WARNING); |
396 | } | 353 | } |
397 | xasprintf(&data, | 354 | xasprintf(&data, "%s %s", data, |
398 | "%s %s", | 355 | perfdata("realpower", (long)ups_realpower, "W", config.check_warn, (long)(config.warning_value), config.check_crit, |
399 | data, | 356 | (long)(config.critical_value), true, 0, false, 0)); |
400 | perfdata("realpower", | ||
401 | (long)ups_realpower, | ||
402 | "W", | ||
403 | config.check_warn, | ||
404 | (long)(config.warning_value), | ||
405 | config.check_crit, | ||
406 | (long)(config.critical_value), | ||
407 | true, | ||
408 | 0, | ||
409 | false, | ||
410 | 0)); | ||
411 | } else { | 357 | } else { |
412 | xasprintf(&data, "%s %s", data, perfdata("realpower", (long)ups_realpower, "W", false, 0, false, 0, true, 0, false, 0)); | 358 | xasprintf(&data, "%s %s", data, perfdata("realpower", (long)ups_realpower, "W", false, 0, false, 0, true, 0, false, 0)); |
413 | } | 359 | } |
@@ -689,12 +635,10 @@ void print_help(void) { | |||
689 | printf("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n"); | 635 | printf("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n"); |
690 | printf(COPYRIGHT, copyright, email); | 636 | printf(COPYRIGHT, copyright, email); |
691 | 637 | ||
692 | printf("%s\n", | 638 | printf("%s\n", _("This plugin tests the UPS service on the specified host. " |
693 | _("This plugin tests the UPS service on the specified host. " | 639 | "Network UPS Tools")); |
694 | "Network UPS Tools")); | 640 | printf("%s\n", _("from www.networkupstools.org must be running for this " |
695 | printf("%s\n", | 641 | "plugin to work.")); |
696 | _("from www.networkupstools.org must be running for this " | ||
697 | "plugin to work.")); | ||
698 | 642 | ||
699 | printf("\n\n"); | 643 | printf("\n\n"); |
700 | 644 | ||
@@ -723,41 +667,31 @@ void print_help(void) { | |||
723 | /* printf (UT_VERBOSE); */ | 667 | /* printf (UT_VERBOSE); */ |
724 | 668 | ||
725 | printf("\n"); | 669 | printf("\n"); |
726 | printf("%s\n", | 670 | printf("%s\n", _("This plugin attempts to determine the status of a UPS " |
727 | _("This plugin attempts to determine the status of a UPS " | 671 | "(Uninterruptible Power")); |
728 | "(Uninterruptible Power")); | 672 | printf("%s\n", _("Supply) on a local or remote host. If the UPS is online " |
729 | printf("%s\n", | 673 | "or calibrating, the")); |
730 | _("Supply) on a local or remote host. If the UPS is online " | 674 | printf("%s\n", _("plugin will return an OK state. If the battery is on it " |
731 | "or calibrating, the")); | 675 | "will return a WARNING")); |
732 | printf("%s\n", | 676 | printf("%s\n", _("state. If the UPS is off or has a low battery the plugin " |
733 | _("plugin will return an OK state. If the battery is on it " | 677 | "will return a CRITICAL")); |
734 | "will return a WARNING")); | ||
735 | printf("%s\n", | ||
736 | _("state. If the UPS is off or has a low battery the plugin " | ||
737 | "will return a CRITICAL")); | ||
738 | printf("%s\n", _("state.")); | 678 | printf("%s\n", _("state.")); |
739 | 679 | ||
740 | printf("\n"); | 680 | printf("\n"); |
741 | printf("%s\n", _("Notes:")); | 681 | printf("%s\n", _("Notes:")); |
742 | printf(" %s\n", | 682 | printf(" %s\n", _("You may also specify a variable to check (such as " |
743 | _("You may also specify a variable to check (such as " | 683 | "temperature, utility voltage,")); |
744 | "temperature, utility voltage,")); | 684 | printf(" %s\n", _("battery load, etc.) as well as warning and critical " |
745 | printf(" %s\n", | 685 | "thresholds for the value")); |
746 | _("battery load, etc.) as well as warning and critical " | 686 | printf(" %s\n", _("of that variable. If the remote host has multiple UPS " |
747 | "thresholds for the value")); | 687 | "that are being monitored")); |
748 | printf(" %s\n", | 688 | printf(" %s\n", _("you will have to use the --ups option to specify which " |
749 | _("of that variable. If the remote host has multiple UPS " | 689 | "UPS to check.")); |
750 | "that are being monitored")); | ||
751 | printf(" %s\n", | ||
752 | _("you will have to use the --ups option to specify which " | ||
753 | "UPS to check.")); | ||
754 | printf("\n"); | 690 | printf("\n"); |
755 | printf(" %s\n", | 691 | printf(" %s\n", _("This plugin requires that the UPSD daemon distributed " |
756 | _("This plugin requires that the UPSD daemon distributed " | 692 | "with Russell Kroll's")); |
757 | "with Russell Kroll's")); | 693 | printf(" %s\n", _("Network UPS Tools be installed on the remote host. If " |
758 | printf(" %s\n", | 694 | "you do not have the")); |
759 | _("Network UPS Tools be installed on the remote host. If " | ||
760 | "you do not have the")); | ||
761 | printf(" %s\n", _("package installed on your system, you can download it from")); | 695 | printf(" %s\n", _("package installed on your system, you can download it from")); |
762 | printf(" %s\n", _("http://www.networkupstools.org")); | 696 | printf(" %s\n", _("http://www.networkupstools.org")); |
763 | 697 | ||