diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-05-18 18:46:30 +0200 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-05-18 18:46:30 +0200 |
| commit | d92bbaef8386e77c00ecdeab9fc722fa4b9106b0 (patch) | |
| tree | d088503ba895da98cbf8558fa1b95951984ed59b | |
| parent | b5de682309589ddb230e04beaaa54d74f2fe70d5 (diff) | |
| download | monitoring-plugins-d92bbaef8386e77c00ecdeab9fc722fa4b9106b0.tar.gz | |
Some more fixes
| -rw-r--r-- | plugins-root/check_icmp.c | 53 | ||||
| -rw-r--r-- | plugins-root/check_icmp.d/check_icmp_helpers.c | 2 | ||||
| -rw-r--r-- | plugins-root/check_icmp.d/check_icmp_helpers.h | 4 | ||||
| -rw-r--r-- | plugins-root/check_icmp.d/config.h | 4 |
4 files changed, 31 insertions, 32 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index d4e55b0d..43eae276 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
| @@ -147,8 +147,8 @@ static void set_source_ip(char *arg, int icmp_sock, sa_family_t addr_family); | |||
| 147 | 147 | ||
| 148 | /* Receiving data */ | 148 | /* Receiving data */ |
| 149 | static int wait_for_reply(check_icmp_socket_set sockset, time_t time_interval, | 149 | static int wait_for_reply(check_icmp_socket_set sockset, time_t time_interval, |
| 150 | unsigned short icmp_pkt_size, unsigned int *pkt_interval, | 150 | unsigned short icmp_pkt_size, time_t *pkt_interval, |
| 151 | unsigned int *target_interval, uint16_t sender_id, ping_target **table, | 151 | time_t *target_interval, uint16_t sender_id, ping_target **table, |
| 152 | unsigned short packets, unsigned short number_of_targets, | 152 | unsigned short packets, unsigned short number_of_targets, |
| 153 | check_icmp_state *program_state); | 153 | check_icmp_state *program_state); |
| 154 | 154 | ||
| @@ -160,12 +160,12 @@ static recvfrom_wto_wrapper recvfrom_wto(check_icmp_socket_set sockset, void *bu | |||
| 160 | struct sockaddr *saddr, time_t *timeout, | 160 | struct sockaddr *saddr, time_t *timeout, |
| 161 | struct timeval *received_timestamp); | 161 | struct timeval *received_timestamp); |
| 162 | static int handle_random_icmp(unsigned char *packet, struct sockaddr_storage *addr, | 162 | static int handle_random_icmp(unsigned char *packet, struct sockaddr_storage *addr, |
| 163 | unsigned int *pkt_interval, unsigned int *target_interval, | 163 | time_t *pkt_interval, time_t *target_interval, uint16_t sender_id, |
| 164 | uint16_t sender_id, ping_target **table, unsigned short packets, | 164 | ping_target **table, unsigned short packets, |
| 165 | unsigned short number_of_targets, check_icmp_state *program_state); | 165 | unsigned short number_of_targets, check_icmp_state *program_state); |
| 166 | 166 | ||
| 167 | /* Sending data */ | 167 | /* Sending data */ |
| 168 | static int send_icmp_ping(check_icmp_socket_set socket, ping_target *host, | 168 | static int send_icmp_ping(check_icmp_socket_set sockset, ping_target *host, |
| 169 | unsigned short icmp_pkt_size, uint16_t sender_id, | 169 | unsigned short icmp_pkt_size, uint16_t sender_id, |
| 170 | check_icmp_state *program_state); | 170 | check_icmp_state *program_state); |
| 171 | 171 | ||
| @@ -194,12 +194,11 @@ static parse_threshold2_helper_wrapper parse_threshold2_helper(char *threshold_s | |||
| 194 | threshold_mode mode); | 194 | threshold_mode mode); |
| 195 | 195 | ||
| 196 | /* main test function */ | 196 | /* main test function */ |
| 197 | static void run_checks(unsigned short icmp_pkt_size, unsigned int *pkt_interval, | 197 | static void run_checks(unsigned short icmp_pkt_size, time_t *pkt_interval, time_t *target_interval, |
| 198 | unsigned int *target_interval, uint16_t sender_id, | 198 | uint16_t sender_id, check_icmp_execution_mode mode, |
| 199 | check_icmp_execution_mode mode, unsigned int max_completion_time, | 199 | unsigned int max_completion_time, struct timeval prog_start, |
| 200 | struct timeval prog_start, ping_target **table, unsigned short packets, | 200 | ping_target **table, unsigned short packets, check_icmp_socket_set sockset, |
| 201 | check_icmp_socket_set sockset, unsigned short number_of_targets, | 201 | unsigned short number_of_targets, check_icmp_state *program_state); |
| 202 | check_icmp_state *program_state); | ||
| 203 | mp_subcheck evaluate_target(ping_target target, check_icmp_mode_switches modes, | 202 | mp_subcheck evaluate_target(ping_target target, check_icmp_mode_switches modes, |
| 204 | check_icmp_threshold warn, check_icmp_threshold crit); | 203 | check_icmp_threshold warn, check_icmp_threshold crit); |
| 205 | 204 | ||
| @@ -683,7 +682,7 @@ static const char *get_icmp_error_msg(unsigned char icmp_type, unsigned char icm | |||
| 683 | } | 682 | } |
| 684 | 683 | ||
| 685 | static int handle_random_icmp(unsigned char *packet, struct sockaddr_storage *addr, | 684 | static int handle_random_icmp(unsigned char *packet, struct sockaddr_storage *addr, |
| 686 | unsigned int *pkt_interval, unsigned int *target_interval, | 685 | time_t *pkt_interval, time_t *target_interval, |
| 687 | const uint16_t sender_id, ping_target **table, unsigned short packets, | 686 | const uint16_t sender_id, ping_target **table, unsigned short packets, |
| 688 | const unsigned short number_of_targets, | 687 | const unsigned short number_of_targets, |
| 689 | check_icmp_state *program_state) { | 688 | check_icmp_state *program_state) { |
| @@ -899,7 +898,7 @@ int main(int argc, char **argv) { | |||
| 899 | struct timeval prog_start; | 898 | struct timeval prog_start; |
| 900 | gettimeofday(&prog_start, NULL); | 899 | gettimeofday(&prog_start, NULL); |
| 901 | 900 | ||
| 902 | unsigned int max_completion_time = | 901 | time_t max_completion_time = |
| 903 | ((config.number_of_targets * config.number_of_packets * config.pkt_interval) + | 902 | ((config.number_of_targets * config.number_of_packets * config.pkt_interval) + |
| 904 | (config.number_of_targets * config.target_interval)) + | 903 | (config.number_of_targets * config.target_interval)) + |
| 905 | (config.number_of_targets * config.number_of_packets * config.crit.rta) + config.crit.rta; | 904 | (config.number_of_targets * config.number_of_packets * config.crit.rta) + config.crit.rta; |
| @@ -916,15 +915,15 @@ int main(int argc, char **argv) { | |||
| 916 | 915 | ||
| 917 | if (debug) { | 916 | if (debug) { |
| 918 | if (max_completion_time > (timeout * 1000000)) { | 917 | if (max_completion_time > (timeout * 1000000)) { |
| 919 | printf("max_completion_time: %u timeout: %u\n", max_completion_time, timeout); | 918 | printf("max_completion_time: %ld timeout: %u\n", max_completion_time, timeout); |
| 920 | printf("Timeout must be at least %u\n", (max_completion_time / 1000000) + 1); | 919 | printf("Timeout must be at least %ld\n", (max_completion_time / 1000000) + 1); |
| 921 | } | 920 | } |
| 922 | } | 921 | } |
| 923 | 922 | ||
| 924 | if (debug) { | 923 | if (debug) { |
| 925 | printf("crit = {%u, %u%%}, warn = {%u, %u%%}\n", config.crit.rta, config.crit.pl, | 924 | printf("crit = {%u, %u%%}, warn = {%u, %u%%}\n", config.crit.rta, config.crit.pl, |
| 926 | config.warn.rta, config.warn.pl); | 925 | config.warn.rta, config.warn.pl); |
| 927 | printf("pkt_interval: %u target_interval: %u\n", config.pkt_interval, | 926 | printf("pkt_interval: %ld target_interval: %ld\n", config.pkt_interval, |
| 928 | config.target_interval); | 927 | config.target_interval); |
| 929 | printf("icmp_pkt_size: %u timeout: %u\n", config.icmp_pkt_size, timeout); | 928 | printf("icmp_pkt_size: %u timeout: %u\n", config.icmp_pkt_size, timeout); |
| 930 | } | 929 | } |
| @@ -949,8 +948,8 @@ int main(int argc, char **argv) { | |||
| 949 | target_index++; | 948 | target_index++; |
| 950 | } | 949 | } |
| 951 | 950 | ||
| 952 | unsigned int pkt_interval = config.pkt_interval; | 951 | time_t pkt_interval = config.pkt_interval; |
| 953 | unsigned int target_interval = config.target_interval; | 952 | time_t target_interval = config.target_interval; |
| 954 | 953 | ||
| 955 | check_icmp_state program_state = check_icmp_state_init(); | 954 | check_icmp_state program_state = check_icmp_state_init(); |
| 956 | 955 | ||
| @@ -975,12 +974,12 @@ int main(int argc, char **argv) { | |||
| 975 | mp_exit(overall); | 974 | mp_exit(overall); |
| 976 | } | 975 | } |
| 977 | 976 | ||
| 978 | static void run_checks(unsigned short icmp_pkt_size, unsigned int *pkt_interval, | 977 | static void run_checks(unsigned short icmp_pkt_size, time_t *pkt_interval, time_t *target_interval, |
| 979 | unsigned int *target_interval, const uint16_t sender_id, | 978 | const uint16_t sender_id, const check_icmp_execution_mode mode, |
| 980 | const check_icmp_execution_mode mode, const unsigned int max_completion_time, | 979 | const unsigned int max_completion_time, const struct timeval prog_start, |
| 981 | const struct timeval prog_start, ping_target **table, | 980 | ping_target **table, const unsigned short packets, |
| 982 | const unsigned short packets, const check_icmp_socket_set sockset, | 981 | const check_icmp_socket_set sockset, const unsigned short number_of_targets, |
| 983 | const unsigned short number_of_targets, check_icmp_state *program_state) { | 982 | check_icmp_state *program_state) { |
| 984 | /* this loop might actually violate the pkt_interval or target_interval | 983 | /* this loop might actually violate the pkt_interval or target_interval |
| 985 | * settings, but only if there aren't any packets on the wire which | 984 | * settings, but only if there aren't any packets on the wire which |
| 986 | * indicates that the target can handle an increased packet rate */ | 985 | * indicates that the target can handle an increased packet rate */ |
| @@ -1065,8 +1064,8 @@ static void run_checks(unsigned short icmp_pkt_size, unsigned int *pkt_interval, | |||
| 1065 | * icmp echo reply : the rest | 1064 | * icmp echo reply : the rest |
| 1066 | */ | 1065 | */ |
| 1067 | static int wait_for_reply(check_icmp_socket_set sockset, const time_t time_interval, | 1066 | static int wait_for_reply(check_icmp_socket_set sockset, const time_t time_interval, |
| 1068 | unsigned short icmp_pkt_size, unsigned int *pkt_interval, | 1067 | unsigned short icmp_pkt_size, time_t *pkt_interval, |
| 1069 | unsigned int *target_interval, uint16_t sender_id, ping_target **table, | 1068 | time_t *target_interval, uint16_t sender_id, ping_target **table, |
| 1070 | const unsigned short packets, const unsigned short number_of_targets, | 1069 | const unsigned short packets, const unsigned short number_of_targets, |
| 1071 | check_icmp_state *program_state) { | 1070 | check_icmp_state *program_state) { |
| 1072 | union icmp_packet packet; | 1071 | union icmp_packet packet; |
| @@ -1568,7 +1567,7 @@ static time_t get_timevaldiff_to_now(struct timeval earlier) { | |||
| 1568 | } | 1567 | } |
| 1569 | 1568 | ||
| 1570 | static add_target_ip_wrapper add_target_ip(struct sockaddr_storage address) { | 1569 | static add_target_ip_wrapper add_target_ip(struct sockaddr_storage address) { |
| 1571 | assert((address.ss_family == AF_INET) || (address.ss_family == AF_INET6)); | 1570 | assert((address.ss_family == AF_INET) || (address.ss_family == AF_INET6)); |
| 1572 | 1571 | ||
| 1573 | if (debug) { | 1572 | if (debug) { |
| 1574 | char straddr[INET6_ADDRSTRLEN]; | 1573 | char straddr[INET6_ADDRSTRLEN]; |
diff --git a/plugins-root/check_icmp.d/check_icmp_helpers.c b/plugins-root/check_icmp.d/check_icmp_helpers.c index 47604952..7a936cc9 100644 --- a/plugins-root/check_icmp.d/check_icmp_helpers.c +++ b/plugins-root/check_icmp.d/check_icmp_helpers.c | |||
| @@ -43,7 +43,7 @@ check_icmp_config check_icmp_config_init() { | |||
| 43 | .need_v4 = false, | 43 | .need_v4 = false, |
| 44 | .need_v6 = false, | 44 | .need_v6 = false, |
| 45 | 45 | ||
| 46 | .sender_id = {}, | 46 | .sender_id = 0, |
| 47 | 47 | ||
| 48 | .mode = MODE_RTA, | 48 | .mode = MODE_RTA, |
| 49 | 49 | ||
diff --git a/plugins-root/check_icmp.d/check_icmp_helpers.h b/plugins-root/check_icmp.d/check_icmp_helpers.h index 713dd8ce..1b9372ce 100644 --- a/plugins-root/check_icmp.d/check_icmp_helpers.h +++ b/plugins-root/check_icmp.d/check_icmp_helpers.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include <netinet/icmp6.h> | 9 | #include <netinet/icmp6.h> |
| 10 | #include <arpa/inet.h> | 10 | #include <arpa/inet.h> |
| 11 | 11 | ||
| 12 | typedef struct rta_host { | 12 | typedef struct ping_target { |
| 13 | unsigned short id; /* id in **table, and icmp pkts */ | 13 | unsigned short id; /* id in **table, and icmp pkts */ |
| 14 | char *msg; /* icmp error message, if any */ | 14 | char *msg; /* icmp error message, if any */ |
| 15 | 15 | ||
| @@ -32,7 +32,7 @@ typedef struct rta_host { | |||
| 32 | 32 | ||
| 33 | bool found_out_of_order_packets; | 33 | bool found_out_of_order_packets; |
| 34 | 34 | ||
| 35 | struct rta_host *next; | 35 | struct ping_target *next; |
| 36 | } ping_target; | 36 | } ping_target; |
| 37 | 37 | ||
| 38 | ping_target ping_target_init(); | 38 | ping_target ping_target_init(); |
diff --git a/plugins-root/check_icmp.d/config.h b/plugins-root/check_icmp.d/config.h index 8e9c96b2..97be7fc1 100644 --- a/plugins-root/check_icmp.d/config.h +++ b/plugins-root/check_icmp.d/config.h | |||
| @@ -60,8 +60,8 @@ typedef struct { | |||
| 60 | unsigned long ttl; | 60 | unsigned long ttl; |
| 61 | unsigned short icmp_data_size; | 61 | unsigned short icmp_data_size; |
| 62 | unsigned short icmp_pkt_size; | 62 | unsigned short icmp_pkt_size; |
| 63 | unsigned int pkt_interval; | 63 | time_t pkt_interval; |
| 64 | unsigned int target_interval; | 64 | time_t target_interval; |
| 65 | unsigned short number_of_packets; | 65 | unsigned short number_of_packets; |
| 66 | 66 | ||
| 67 | char *source_ip; | 67 | char *source_ip; |
