diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-18 14:54:48 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-18 14:54:48 (GMT) |
commit | 1ba64fb56683c7418d4d87565cdd52421edbb8c6 (patch) | |
tree | ecdc8a9e67ae85709b9a17f71856f5662346f88b /plugins/check_nt.c | |
parent | ee80cc259190563ddb29eb780e13eb038a4ff680 (diff) | |
download | monitoring-plugins-1ba64fb56683c7418d4d87565cdd52421edbb8c6.tar.gz |
check_nt: Use C99 booleans
Diffstat (limited to 'plugins/check_nt.c')
-rw-r--r-- | plugins/check_nt.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c index d73d83c..19c050d 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c | |||
@@ -67,17 +67,17 @@ char *req_password=NULL; | |||
67 | unsigned long lvalue_list[MAX_VALUE_LIST]; | 67 | unsigned long lvalue_list[MAX_VALUE_LIST]; |
68 | unsigned long warning_value=0L; | 68 | unsigned long warning_value=0L; |
69 | unsigned long critical_value=0L; | 69 | unsigned long critical_value=0L; |
70 | int check_warning_value=FALSE; | 70 | bool check_warning_value=false; |
71 | int check_critical_value=FALSE; | 71 | bool check_critical_value=false; |
72 | enum checkvars vars_to_check = CHECK_NONE; | 72 | enum checkvars vars_to_check = CHECK_NONE; |
73 | int show_all=FALSE; | 73 | bool show_all = false; |
74 | 74 | ||
75 | char recv_buffer[MAX_INPUT_BUFFER]; | 75 | char recv_buffer[MAX_INPUT_BUFFER]; |
76 | 76 | ||
77 | void fetch_data (const char* address, int port, const char* sendb); | 77 | void fetch_data (const char* address, int port, const char* sendb); |
78 | int process_arguments(int, char **); | 78 | int process_arguments(int, char **); |
79 | void preparelist(char *string); | 79 | void preparelist(char *string); |
80 | int strtoularray(unsigned long *array, char *string, const char *delim); | 80 | bool strtoularray(unsigned long *array, char *string, const char *delim); |
81 | void print_help(void); | 81 | void print_help(void); |
82 | void print_usage(void); | 82 | void print_usage(void); |
83 | 83 | ||
@@ -113,8 +113,8 @@ int main(int argc, char **argv){ | |||
113 | int uphours=0; | 113 | int uphours=0; |
114 | int upminutes=0; | 114 | int upminutes=0; |
115 | 115 | ||
116 | int isPercent = FALSE; | 116 | bool isPercent = false; |
117 | int allRight = FALSE; | 117 | bool allRight = false; |
118 | 118 | ||
119 | setlocale (LC_ALL, ""); | 119 | setlocale (LC_ALL, ""); |
120 | bindtextdomain (PACKAGE, LOCALEDIR); | 120 | bindtextdomain (PACKAGE, LOCALEDIR); |
@@ -151,7 +151,7 @@ int main(int argc, char **argv){ | |||
151 | 151 | ||
152 | if (value_list==NULL) | 152 | if (value_list==NULL) |
153 | output_message = strdup (_("missing -l parameters")); | 153 | output_message = strdup (_("missing -l parameters")); |
154 | else if (strtoularray(lvalue_list,value_list,",")==FALSE) | 154 | else if (! strtoularray(lvalue_list,value_list,",")) |
155 | output_message = strdup (_("wrong -l parameter.")); | 155 | output_message = strdup (_("wrong -l parameter.")); |
156 | else { | 156 | else { |
157 | /* -l parameters is present with only integers */ | 157 | /* -l parameters is present with only integers */ |
@@ -224,9 +224,9 @@ int main(int argc, char **argv){ | |||
224 | 224 | ||
225 | xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime); | 225 | xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime); |
226 | 226 | ||
227 | if (check_critical_value==TRUE && uptime <= critical_value) | 227 | if (check_critical_value && uptime <= critical_value) |
228 | return_code=STATE_CRITICAL; | 228 | return_code=STATE_CRITICAL; |
229 | else if (check_warning_value==TRUE && uptime <= warning_value) | 229 | else if (check_warning_value && uptime <= warning_value) |
230 | return_code=STATE_WARNING; | 230 | return_code=STATE_WARNING; |
231 | else | 231 | else |
232 | return_code=STATE_OK; | 232 | return_code=STATE_OK; |
@@ -261,9 +261,9 @@ int main(int argc, char **argv){ | |||
261 | (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, | 261 | (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, |
262 | critical_used_space / 1073741824, total_disk_space / 1073741824); | 262 | critical_used_space / 1073741824, total_disk_space / 1073741824); |
263 | 263 | ||
264 | if(check_critical_value==TRUE && percent_used_space >= critical_value) | 264 | if(check_critical_value && percent_used_space >= critical_value) |
265 | return_code=STATE_CRITICAL; | 265 | return_code=STATE_CRITICAL; |
266 | else if (check_warning_value==TRUE && percent_used_space >= warning_value) | 266 | else if (check_warning_value && percent_used_space >= warning_value) |
267 | return_code=STATE_WARNING; | 267 | return_code=STATE_WARNING; |
268 | else | 268 | else |
269 | return_code=STATE_OK; | 269 | return_code=STATE_OK; |
@@ -285,7 +285,7 @@ int main(int argc, char **argv){ | |||
285 | else { | 285 | else { |
286 | preparelist(value_list); /* replace , between services with & to send the request */ | 286 | preparelist(value_list); /* replace , between services with & to send the request */ |
287 | xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, | 287 | xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, |
288 | (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list); | 288 | (show_all) ? "ShowAll" : "ShowFail",value_list); |
289 | fetch_data (server_address, server_port, send_buffer); | 289 | fetch_data (server_address, server_port, send_buffer); |
290 | numstr = strtok(recv_buffer,"&"); | 290 | numstr = strtok(recv_buffer,"&"); |
291 | if (numstr == NULL) | 291 | if (numstr == NULL) |
@@ -321,9 +321,9 @@ int main(int argc, char **argv){ | |||
321 | warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567); | 321 | warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567); |
322 | 322 | ||
323 | return_code=STATE_OK; | 323 | return_code=STATE_OK; |
324 | if(check_critical_value==TRUE && percent_used_space >= critical_value) | 324 | if(check_critical_value && percent_used_space >= critical_value) |
325 | return_code=STATE_CRITICAL; | 325 | return_code=STATE_CRITICAL; |
326 | else if (check_warning_value==TRUE && percent_used_space >= warning_value) | 326 | else if (check_warning_value && percent_used_space >= warning_value) |
327 | return_code=STATE_WARNING; | 327 | return_code=STATE_WARNING; |
328 | 328 | ||
329 | break; | 329 | break; |
@@ -371,7 +371,7 @@ int main(int argc, char **argv){ | |||
371 | else if (isPercent) | 371 | else if (isPercent) |
372 | { | 372 | { |
373 | counter_unit = strdup ("%"); | 373 | counter_unit = strdup ("%"); |
374 | allRight = TRUE; | 374 | allRight = true; |
375 | } | 375 | } |
376 | 376 | ||
377 | if ((counter_unit != NULL) && (!allRight)) | 377 | if ((counter_unit != NULL) && (!allRight)) |
@@ -391,7 +391,7 @@ int main(int argc, char **argv){ | |||
391 | if ((fmaxval == 0) && (maxval == errcvt)) | 391 | if ((fmaxval == 0) && (maxval == errcvt)) |
392 | output_message = strdup (_("Maximum value contains non-numbers")); | 392 | output_message = strdup (_("Maximum value contains non-numbers")); |
393 | else | 393 | else |
394 | allRight = TRUE; /* Everything is OK. */ | 394 | allRight = true; /* Everything is OK. */ |
395 | 395 | ||
396 | } | 396 | } |
397 | } | 397 | } |
@@ -418,9 +418,9 @@ int main(int argc, char **argv){ | |||
418 | 418 | ||
419 | if (critical_value > warning_value) | 419 | if (critical_value > warning_value) |
420 | { /* Normal thresholds */ | 420 | { /* Normal thresholds */ |
421 | if (check_critical_value == TRUE && counter_value >= critical_value) | 421 | if (check_critical_value && counter_value >= critical_value) |
422 | return_code = STATE_CRITICAL; | 422 | return_code = STATE_CRITICAL; |
423 | else if (check_warning_value == TRUE && counter_value >= warning_value) | 423 | else if (check_warning_value && counter_value >= warning_value) |
424 | return_code = STATE_WARNING; | 424 | return_code = STATE_WARNING; |
425 | else | 425 | else |
426 | return_code = STATE_OK; | 426 | return_code = STATE_OK; |
@@ -428,9 +428,9 @@ int main(int argc, char **argv){ | |||
428 | else | 428 | else |
429 | { /* inverse thresholds */ | 429 | { /* inverse thresholds */ |
430 | return_code = STATE_OK; | 430 | return_code = STATE_OK; |
431 | if (check_critical_value == TRUE && counter_value <= critical_value) | 431 | if (check_critical_value && counter_value <= critical_value) |
432 | return_code = STATE_CRITICAL; | 432 | return_code = STATE_CRITICAL; |
433 | else if (check_warning_value == TRUE && counter_value <= warning_value) | 433 | else if (check_warning_value && counter_value <= warning_value) |
434 | return_code = STATE_WARNING; | 434 | return_code = STATE_WARNING; |
435 | } | 435 | } |
436 | break; | 436 | break; |
@@ -448,17 +448,17 @@ int main(int argc, char **argv){ | |||
448 | output_message = strdup (description); | 448 | output_message = strdup (description); |
449 | 449 | ||
450 | if (critical_value > warning_value) { /* Normal thresholds */ | 450 | if (critical_value > warning_value) { /* Normal thresholds */ |
451 | if(check_critical_value==TRUE && age_in_minutes >= critical_value) | 451 | if(check_critical_value && age_in_minutes >= critical_value) |
452 | return_code=STATE_CRITICAL; | 452 | return_code=STATE_CRITICAL; |
453 | else if (check_warning_value==TRUE && age_in_minutes >= warning_value) | 453 | else if (check_warning_value && age_in_minutes >= warning_value) |
454 | return_code=STATE_WARNING; | 454 | return_code=STATE_WARNING; |
455 | else | 455 | else |
456 | return_code=STATE_OK; | 456 | return_code=STATE_OK; |
457 | } | 457 | } |
458 | else { /* inverse thresholds */ | 458 | else { /* inverse thresholds */ |
459 | if(check_critical_value==TRUE && age_in_minutes <= critical_value) | 459 | if(check_critical_value && age_in_minutes <= critical_value) |
460 | return_code=STATE_CRITICAL; | 460 | return_code=STATE_CRITICAL; |
461 | else if (check_warning_value==TRUE && age_in_minutes <= warning_value) | 461 | else if (check_warning_value && age_in_minutes <= warning_value) |
462 | return_code=STATE_WARNING; | 462 | return_code=STATE_WARNING; |
463 | else | 463 | else |
464 | return_code=STATE_OK; | 464 | return_code=STATE_OK; |
@@ -600,15 +600,15 @@ int process_arguments(int argc, char **argv){ | |||
600 | break; | 600 | break; |
601 | case 'w': /* warning threshold */ | 601 | case 'w': /* warning threshold */ |
602 | warning_value=strtoul(optarg,NULL,10); | 602 | warning_value=strtoul(optarg,NULL,10); |
603 | check_warning_value=TRUE; | 603 | check_warning_value=true; |
604 | break; | 604 | break; |
605 | case 'c': /* critical threshold */ | 605 | case 'c': /* critical threshold */ |
606 | critical_value=strtoul(optarg,NULL,10); | 606 | critical_value=strtoul(optarg,NULL,10); |
607 | check_critical_value=TRUE; | 607 | check_critical_value=true; |
608 | break; | 608 | break; |
609 | case 'd': /* Display select for services */ | 609 | case 'd': /* Display select for services */ |
610 | if (!strcmp(optarg,"SHOWALL")) | 610 | if (!strcmp(optarg,"SHOWALL")) |
611 | show_all = TRUE; | 611 | show_all = true; |
612 | break; | 612 | break; |
613 | case 'u': | 613 | case 'u': |
614 | socket_timeout_state=STATE_UNKNOWN; | 614 | socket_timeout_state=STATE_UNKNOWN; |
@@ -646,7 +646,7 @@ void fetch_data (const char *address, int port, const char *sendb) { | |||
646 | die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer); | 646 | die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer); |
647 | } | 647 | } |
648 | 648 | ||
649 | int strtoularray(unsigned long *array, char *string, const char *delim) { | 649 | bool strtoularray(unsigned long *array, char *string, const char *delim) { |
650 | /* split a <delim> delimited string into a long array */ | 650 | /* split a <delim> delimited string into a long array */ |
651 | int idx=0; | 651 | int idx=0; |
652 | char *t1; | 652 | char *t1; |
@@ -660,9 +660,9 @@ int strtoularray(unsigned long *array, char *string, const char *delim) { | |||
660 | array[idx]=strtoul(t1,NULL,10); | 660 | array[idx]=strtoul(t1,NULL,10); |
661 | idx++; | 661 | idx++; |
662 | } else | 662 | } else |
663 | return FALSE; | 663 | return false; |
664 | } | 664 | } |
665 | return TRUE; | 665 | return true; |
666 | } | 666 | } |
667 | 667 | ||
668 | void preparelist(char *string) { | 668 | void preparelist(char *string) { |