summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2024-10-18 23:21:22 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2024-10-18 23:21:22 (GMT)
commit4541b2b3571fd7806313187aa852bfe7c2ad5235 (patch)
treeb08dfedcdb4711378f52f91f3ae31ee93063ae65
parentc0a3bd07057f7e6b000d477088424cf71f89e3e7 (diff)
downloadmonitoring-plugins-4541b2b3571fd7806313187aa852bfe7c2ad5235.tar.gz
check_ups: clang-format again
-rw-r--r--plugins/check_ups.c144
1 files changed, 105 insertions, 39 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index e5badc8..c2451ab 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -235,9 +235,19 @@ 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, "%s", 238 xasprintf(&data,
239 perfdata("voltage", (long)(1000 * ups_utility_voltage), "mV", config.check_warn, (long)(1000 * config.warning_value), config.check_crit, 239 "%s",
240 (long)(1000 * config.critical_value), true, 0, false, 0)); 240 perfdata("voltage",
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));
241 } else { 251 } else {
242 xasprintf(&data, "%s", perfdata("voltage", (long)(1000 * ups_utility_voltage), "mV", false, 0, false, 0, true, 0, false, 0)); 252 xasprintf(&data, "%s", perfdata("voltage", (long)(1000 * ups_utility_voltage), "mV", false, 0, false, 0, true, 0, false, 0));
243 } 253 }
@@ -262,9 +272,20 @@ int main(int argc, char **argv) {
262 } else if (config.check_warn && ups_battery_percent <= config.warning_value) { 272 } else if (config.check_warn && ups_battery_percent <= config.warning_value) {
263 result = max_state(result, STATE_WARNING); 273 result = max_state(result, STATE_WARNING);
264 } 274 }
265 xasprintf(&data, "%s %s", data, 275 xasprintf(&data,
266 perfdata("battery", (long)ups_battery_percent, "%", config.check_warn, (long)(config.warning_value), config.check_crit, (long)(config.critical_value), true, 276 "%s %s",
267 0, true, 100)); 277 data,
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));
268 } else { 289 } else {
269 xasprintf(&data, "%s %s", data, perfdata("battery", (long)ups_battery_percent, "%", false, 0, false, 0, true, 0, true, 100)); 290 xasprintf(&data, "%s %s", data, perfdata("battery", (long)ups_battery_percent, "%", false, 0, false, 0, true, 0, true, 100));
270 } 291 }
@@ -289,9 +310,20 @@ int main(int argc, char **argv) {
289 } else if (config.check_warn && ups_load_percent >= config.warning_value) { 310 } else if (config.check_warn && ups_load_percent >= config.warning_value) {
290 result = max_state(result, STATE_WARNING); 311 result = max_state(result, STATE_WARNING);
291 } 312 }
292 xasprintf(&data, "%s %s", data, 313 xasprintf(&data,
293 perfdata("load", (long)ups_load_percent, "%", config.check_warn, (long)(config.warning_value), config.check_crit, (long)(config.critical_value), true, 0, 314 "%s %s",
294 true, 100)); 315 data,
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));
295 } else { 327 } else {
296 xasprintf(&data, "%s %s", data, perfdata("load", (long)ups_load_percent, "%", false, 0, false, 0, true, 0, true, 100)); 328 xasprintf(&data, "%s %s", data, perfdata("load", (long)ups_load_percent, "%", false, 0, false, 0, true, 0, true, 100));
297 } 329 }
@@ -325,9 +357,20 @@ int main(int argc, char **argv) {
325 } else if (config.check_warn && ups_temperature >= config.warning_value) { 357 } else if (config.check_warn && ups_temperature >= config.warning_value) {
326 result = max_state(result, STATE_WARNING); 358 result = max_state(result, STATE_WARNING);
327 } 359 }
328 xasprintf(&data, "%s %s", data, 360 xasprintf(&data,
329 perfdata("temp", (long)ups_temperature, tunits, config.check_warn, (long)(config.warning_value), config.check_crit, (long)(config.critical_value), true, 0, 361 "%s %s",
330 false, 0)); 362 data,
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));
331 } else { 374 } else {
332 xasprintf(&data, "%s %s", data, perfdata("temp", (long)ups_temperature, tunits, false, 0, false, 0, true, 0, false, 0)); 375 xasprintf(&data, "%s %s", data, perfdata("temp", (long)ups_temperature, tunits, false, 0, false, 0, true, 0, false, 0));
333 } 376 }
@@ -351,9 +394,20 @@ int main(int argc, char **argv) {
351 } else if (config.check_warn && ups_realpower >= config.warning_value) { 394 } else if (config.check_warn && ups_realpower >= config.warning_value) {
352 result = max_state(result, STATE_WARNING); 395 result = max_state(result, STATE_WARNING);
353 } 396 }
354 xasprintf(&data, "%s %s", data, 397 xasprintf(&data,
355 perfdata("realpower", (long)ups_realpower, "W", config.check_warn, (long)(config.warning_value), config.check_crit, (long)(config.critical_value), true, 0, 398 "%s %s",
356 false, 0)); 399 data,
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));
357 } else { 411 } else {
358 xasprintf(&data, "%s %s", data, perfdata("realpower", (long)ups_realpower, "W", false, 0, false, 0, true, 0, false, 0)); 412 xasprintf(&data, "%s %s", data, perfdata("realpower", (long)ups_realpower, "W", false, 0, false, 0, true, 0, false, 0));
359 } 413 }
@@ -635,10 +689,12 @@ void print_help(void) {
635 printf("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n"); 689 printf("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n");
636 printf(COPYRIGHT, copyright, email); 690 printf(COPYRIGHT, copyright, email);
637 691
638 printf("%s\n", _("This plugin tests the UPS service on the specified host. " 692 printf("%s\n",
639 "Network UPS Tools")); 693 _("This plugin tests the UPS service on the specified host. "
640 printf("%s\n", _("from www.networkupstools.org must be running for this " 694 "Network UPS Tools"));
641 "plugin to work.")); 695 printf("%s\n",
696 _("from www.networkupstools.org must be running for this "
697 "plugin to work."));
642 698
643 printf("\n\n"); 699 printf("\n\n");
644 700
@@ -667,31 +723,41 @@ void print_help(void) {
667 /* printf (UT_VERBOSE); */ 723 /* printf (UT_VERBOSE); */
668 724
669 printf("\n"); 725 printf("\n");
670 printf("%s\n", _("This plugin attempts to determine the status of a UPS " 726 printf("%s\n",
671 "(Uninterruptible Power")); 727 _("This plugin attempts to determine the status of a UPS "
672 printf("%s\n", _("Supply) on a local or remote host. If the UPS is online " 728 "(Uninterruptible Power"));
673 "or calibrating, the")); 729 printf("%s\n",
674 printf("%s\n", _("plugin will return an OK state. If the battery is on it " 730 _("Supply) on a local or remote host. If the UPS is online "
675 "will return a WARNING")); 731 "or calibrating, the"));
676 printf("%s\n", _("state. If the UPS is off or has a low battery the plugin " 732 printf("%s\n",
677 "will return a CRITICAL")); 733 _("plugin will return an OK state. If the battery is on it "
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"));
678 printf("%s\n", _("state.")); 738 printf("%s\n", _("state."));
679 739
680 printf("\n"); 740 printf("\n");
681 printf("%s\n", _("Notes:")); 741 printf("%s\n", _("Notes:"));
682 printf(" %s\n", _("You may also specify a variable to check (such as " 742 printf(" %s\n",
683 "temperature, utility voltage,")); 743 _("You may also specify a variable to check (such as "
684 printf(" %s\n", _("battery load, etc.) as well as warning and critical " 744 "temperature, utility voltage,"));
685 "thresholds for the value")); 745 printf(" %s\n",
686 printf(" %s\n", _("of that variable. If the remote host has multiple UPS " 746 _("battery load, etc.) as well as warning and critical "
687 "that are being monitored")); 747 "thresholds for the value"));
688 printf(" %s\n", _("you will have to use the --ups option to specify which " 748 printf(" %s\n",
689 "UPS to check.")); 749 _("of that variable. If the remote host has multiple UPS "
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."));
690 printf("\n"); 754 printf("\n");
691 printf(" %s\n", _("This plugin requires that the UPSD daemon distributed " 755 printf(" %s\n",
692 "with Russell Kroll's")); 756 _("This plugin requires that the UPSD daemon distributed "
693 printf(" %s\n", _("Network UPS Tools be installed on the remote host. If " 757 "with Russell Kroll's"));
694 "you do not have the")); 758 printf(" %s\n",
759 _("Network UPS Tools be installed on the remote host. If "
760 "you do not have the"));
695 printf(" %s\n", _("package installed on your system, you can download it from")); 761 printf(" %s\n", _("package installed on your system, you can download it from"));
696 printf(" %s\n", _("http://www.networkupstools.org")); 762 printf(" %s\n", _("http://www.networkupstools.org"));
697 763