summaryrefslogtreecommitdiffstats
path: root/plugins/check_ups.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_ups.c')
-rw-r--r--plugins/check_ups.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index 68737c4..d1ded62 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -75,8 +75,8 @@ char *server_address;
75char *ups_name = NULL; 75char *ups_name = NULL;
76double warning_value = 0.0; 76double warning_value = 0.0;
77double critical_value = 0.0; 77double critical_value = 0.0;
78int check_warn = FALSE; 78bool check_warn = false;
79int check_crit = FALSE; 79bool check_crit = false;
80int check_variable = UPS_NONE; 80int check_variable = UPS_NONE;
81int supported_options = UPS_NONE; 81int supported_options = UPS_NONE;
82int status = UPSSTATUS_NONE; 82int status = UPSSTATUS_NONE;
@@ -86,7 +86,7 @@ double ups_battery_percent = 0.0;
86double ups_load_percent = 0.0; 86double ups_load_percent = 0.0;
87double ups_temperature = 0.0; 87double ups_temperature = 0.0;
88char *ups_status; 88char *ups_status;
89int temp_output_c = 0; 89bool temp_output_c = false;
90 90
91int determine_status (void); 91int determine_status (void);
92int get_ups_variable (const char *, char *); 92int get_ups_variable (const char *, char *);
@@ -205,21 +205,21 @@ main (int argc, char **argv)
205 ups_utility_deviation = ups_utility_voltage - 120.0; 205 ups_utility_deviation = ups_utility_voltage - 120.0;
206 206
207 if (check_variable == UPS_UTILITY) { 207 if (check_variable == UPS_UTILITY) {
208 if (check_crit==TRUE && ups_utility_deviation>=critical_value) { 208 if (check_crit && ups_utility_deviation>=critical_value) {
209 result = STATE_CRITICAL; 209 result = STATE_CRITICAL;
210 } 210 }
211 else if (check_warn==TRUE && ups_utility_deviation>=warning_value) { 211 else if (check_warn && ups_utility_deviation>=warning_value) {
212 result = max_state (result, STATE_WARNING); 212 result = max_state (result, STATE_WARNING);
213 } 213 }
214 xasprintf (&data, "%s", 214 xasprintf (&data, "%s",
215 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", 215 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
216 check_warn, (long)(1000*warning_value), 216 check_warn, (long)(1000*warning_value),
217 check_crit, (long)(1000*critical_value), 217 check_crit, (long)(1000*critical_value),
218 TRUE, 0, FALSE, 0)); 218 true, 0, false, 0));
219 } else { 219 } else {
220 xasprintf (&data, "%s", 220 xasprintf (&data, "%s",
221 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", 221 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
222 FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); 222 false, 0, false, 0, true, 0, false, 0));
223 } 223 }
224 } 224 }
225 225
@@ -234,21 +234,21 @@ main (int argc, char **argv)
234 xasprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent); 234 xasprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent);
235 235
236 if (check_variable == UPS_BATTPCT) { 236 if (check_variable == UPS_BATTPCT) {
237 if (check_crit==TRUE && ups_battery_percent <= critical_value) { 237 if (check_crit && ups_battery_percent <= critical_value) {
238 result = STATE_CRITICAL; 238 result = STATE_CRITICAL;
239 } 239 }
240 else if (check_warn==TRUE && ups_battery_percent<=warning_value) { 240 else if (check_warn && ups_battery_percent<=warning_value) {
241 result = max_state (result, STATE_WARNING); 241 result = max_state (result, STATE_WARNING);
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)(warning_value), 245 check_warn, (long)(warning_value),
246 check_crit, (long)(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,
250 perfdata ("battery", (long)ups_battery_percent, "%", 250 perfdata ("battery", (long)ups_battery_percent, "%",
251 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100)); 251 false, 0, false, 0, true, 0, true, 100));
252 } 252 }
253 } 253 }
254 254
@@ -263,21 +263,21 @@ main (int argc, char **argv)
263 xasprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent); 263 xasprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent);
264 264
265 if (check_variable == UPS_LOADPCT) { 265 if (check_variable == UPS_LOADPCT) {
266 if (check_crit==TRUE && ups_load_percent>=critical_value) { 266 if (check_crit && ups_load_percent>=critical_value) {
267 result = STATE_CRITICAL; 267 result = STATE_CRITICAL;
268 } 268 }
269 else if (check_warn==TRUE && ups_load_percent>=warning_value) { 269 else if (check_warn && ups_load_percent>=warning_value) {
270 result = max_state (result, STATE_WARNING); 270 result = max_state (result, STATE_WARNING);
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)(warning_value), 274 check_warn, (long)(warning_value),
275 check_crit, (long)(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,
279 perfdata ("load", (long)ups_load_percent, "%", 279 perfdata ("load", (long)ups_load_percent, "%",
280 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100)); 280 false, 0, false, 0, true, 0, true, 100));
281 } 281 }
282 } 282 }
283 283
@@ -300,21 +300,21 @@ main (int argc, char **argv)
300 } 300 }
301 301
302 if (check_variable == UPS_TEMP) { 302 if (check_variable == UPS_TEMP) {
303 if (check_crit==TRUE && ups_temperature>=critical_value) { 303 if (check_crit && ups_temperature>=critical_value) {
304 result = STATE_CRITICAL; 304 result = STATE_CRITICAL;
305 } 305 }
306 else if (check_warn == TRUE && ups_temperature>=warning_value) { 306 else if (check_warn && ups_temperature>=warning_value) {
307 result = max_state (result, STATE_WARNING); 307 result = max_state (result, STATE_WARNING);
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)(warning_value), 311 check_warn, (long)(warning_value),
312 check_crit, (long)(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,
316 perfdata ("temp", (long)ups_temperature, tunits, 316 perfdata ("temp", (long)ups_temperature, tunits,
317 FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); 317 false, 0, false, 0, true, 0, false, 0));
318 } 318 }
319 } 319 }
320 320
@@ -508,7 +508,7 @@ process_arguments (int argc, char **argv)
508 } 508 }
509 break; 509 break;
510 case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Fahrenheit) */ 510 case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Fahrenheit) */
511 temp_output_c = 1; 511 temp_output_c = true;
512 break; 512 break;
513 case 'u': /* ups name */ 513 case 'u': /* ups name */
514 ups_name = optarg; 514 ups_name = optarg;
@@ -524,7 +524,7 @@ process_arguments (int argc, char **argv)
524 case 'c': /* critical time threshold */ 524 case 'c': /* critical time threshold */
525 if (is_intnonneg (optarg)) { 525 if (is_intnonneg (optarg)) {
526 critical_value = atoi (optarg); 526 critical_value = atoi (optarg);
527 check_crit = TRUE; 527 check_crit = true;
528 } 528 }
529 else { 529 else {
530 usage2 (_("Critical time must be a positive integer"), optarg); 530 usage2 (_("Critical time must be a positive integer"), optarg);
@@ -533,7 +533,7 @@ process_arguments (int argc, char **argv)
533 case 'w': /* warning time threshold */ 533 case 'w': /* warning time threshold */
534 if (is_intnonneg (optarg)) { 534 if (is_intnonneg (optarg)) {
535 warning_value = atoi (optarg); 535 warning_value = atoi (optarg);
536 check_warn = TRUE; 536 check_warn = true;
537 } 537 }
538 else { 538 else {
539 usage2 (_("Warning time must be a positive integer"), optarg); 539 usage2 (_("Warning time must be a positive integer"), optarg);