diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-19 10:22:40 +0200 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-19 10:22:40 +0200 |
commit | efe79595d3813b81f873f125260d0f9937535134 (patch) | |
tree | bb871753b0c5f8c7a45a6f55c3977c060ead765c | |
parent | 93a4bae90d7548fef77182e9624f51fbc6e8c360 (diff) | |
download | monitoring-plugins-efe79595d3813b81f873f125260d0f9937535134.tar.gz |
check_ntp: Use C99 booleans
-rw-r--r-- | plugins/check_ntp.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 99537c88..61b2d699 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c | |||
@@ -40,10 +40,10 @@ const char *email = "devel@monitoring-plugins.org"; | |||
40 | 40 | ||
41 | static char *server_address=NULL; | 41 | static char *server_address=NULL; |
42 | static int verbose=0; | 42 | static int verbose=0; |
43 | static short do_offset=0; | 43 | static bool do_offset = false; |
44 | static char *owarn="60"; | 44 | static char *owarn="60"; |
45 | static char *ocrit="120"; | 45 | static char *ocrit="120"; |
46 | static short do_jitter=0; | 46 | static bool do_jitter = false; |
47 | static char *jwarn="5000"; | 47 | static char *jwarn="5000"; |
48 | static char *jcrit="10000"; | 48 | static char *jcrit="10000"; |
49 | 49 | ||
@@ -513,7 +513,8 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){ | |||
513 | 513 | ||
514 | /* XXX handle responses with the error bit set */ | 514 | /* XXX handle responses with the error bit set */ |
515 | double jitter_request(int *status){ | 515 | double jitter_request(int *status){ |
516 | int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0; | 516 | int conn=-1, i, npeers=0, num_candidates=0; |
517 | bool syncsource_found = false; | ||
517 | int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; | 518 | int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; |
518 | int peers_size=0, peer_offset=0; | 519 | int peers_size=0, peer_offset=0; |
519 | ntp_assoc_status_pair *peers=NULL; | 520 | ntp_assoc_status_pair *peers=NULL; |
@@ -570,7 +571,7 @@ double jitter_request(int *status){ | |||
570 | if (PEER_SEL(peers[i].status) >= PEER_INCLUDED){ | 571 | if (PEER_SEL(peers[i].status) >= PEER_INCLUDED){ |
571 | num_candidates++; | 572 | num_candidates++; |
572 | if(PEER_SEL(peers[i].status) >= PEER_SYNCSOURCE){ | 573 | if(PEER_SEL(peers[i].status) >= PEER_SYNCSOURCE){ |
573 | syncsource_found=1; | 574 | syncsource_found = true; |
574 | min_peer_sel=PEER_SYNCSOURCE; | 575 | min_peer_sel=PEER_SYNCSOURCE; |
575 | } | 576 | } |
576 | } | 577 | } |
@@ -699,23 +700,23 @@ int process_arguments(int argc, char **argv){ | |||
699 | verbose++; | 700 | verbose++; |
700 | break; | 701 | break; |
701 | case 'w': | 702 | case 'w': |
702 | do_offset=1; | 703 | do_offset = true; |
703 | owarn = optarg; | 704 | owarn = optarg; |
704 | break; | 705 | break; |
705 | case 'c': | 706 | case 'c': |
706 | do_offset=1; | 707 | do_offset = true; |
707 | ocrit = optarg; | 708 | ocrit = optarg; |
708 | break; | 709 | break; |
709 | case 'j': | 710 | case 'j': |
710 | do_jitter=1; | 711 | do_jitter = true; |
711 | jwarn = optarg; | 712 | jwarn = optarg; |
712 | break; | 713 | break; |
713 | case 'k': | 714 | case 'k': |
714 | do_jitter=1; | 715 | do_jitter = true; |
715 | jcrit = optarg; | 716 | jcrit = optarg; |
716 | break; | 717 | break; |
717 | case 'H': | 718 | case 'H': |
718 | if(is_host(optarg) == FALSE) | 719 | if(!is_host(optarg)) |
719 | usage2(_("Invalid hostname/address"), optarg); | 720 | usage2(_("Invalid hostname/address"), optarg); |
720 | server_address = strdup(optarg); | 721 | server_address = strdup(optarg); |
721 | break; | 722 | break; |
@@ -749,9 +750,9 @@ int process_arguments(int argc, char **argv){ | |||
749 | char *perfd_offset (double offset) | 750 | char *perfd_offset (double offset) |
750 | { | 751 | { |
751 | return fperfdata ("offset", offset, "s", | 752 | return fperfdata ("offset", offset, "s", |
752 | TRUE, offset_thresholds->warning->end, | 753 | true, offset_thresholds->warning->end, |
753 | TRUE, offset_thresholds->critical->end, | 754 | true, offset_thresholds->critical->end, |
754 | FALSE, 0, FALSE, 0); | 755 | false, 0, false, 0); |
755 | } | 756 | } |
756 | 757 | ||
757 | char *perfd_jitter (double jitter) | 758 | char *perfd_jitter (double jitter) |
@@ -759,7 +760,7 @@ char *perfd_jitter (double jitter) | |||
759 | return fperfdata ("jitter", jitter, "s", | 760 | return fperfdata ("jitter", jitter, "s", |
760 | do_jitter, jitter_thresholds->warning->end, | 761 | do_jitter, jitter_thresholds->warning->end, |
761 | do_jitter, jitter_thresholds->critical->end, | 762 | do_jitter, jitter_thresholds->critical->end, |
762 | TRUE, 0, FALSE, 0); | 763 | true, 0, false, 0); |
763 | } | 764 | } |
764 | 765 | ||
765 | int main(int argc, char *argv[]){ | 766 | int main(int argc, char *argv[]){ |