From 1372654e8a2d392db35aae8f62586d55319ccb3c Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 11 Jun 2026 02:40:07 +0200 Subject: Check ntp time delay (#2277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * check_ntp_time: add polling delay NTP server can have rate limiting which might be triggered by check_ntp_time due to many requests in a short time span. This patch adds a default delay (of 0.5s) between requests to each server and a command line option (--poll-delay) to make this delay configurable. Co-authored-by: Lorenz Kästle * check_ntp_time: verify whether socket path fits into address struct check_ntp_time could be give a too long (>108 bytes) socket path to work with, which would potentially crash the program. This patch validates to length beforehand and stops execution in that case. Co-authored-by: Lorenz Kästle --------- Co-authored-by: Paul Crawford Co-authored-by: Lorenz Kästle --- plugins/check_ntp_time.d/config.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/check_ntp_time.d/config.h') diff --git a/plugins/check_ntp_time.d/config.h b/plugins/check_ntp_time.d/config.h index 9bbd82aa..c1aa142c 100644 --- a/plugins/check_ntp_time.d/config.h +++ b/plugins/check_ntp_time.d/config.h @@ -5,6 +5,9 @@ #include "thresholds.h" #include +/* Time in microseconds to delay between polling to avoid a blocking response. */ +const long default_polling_delay = 500000L; + typedef struct { char *server_address; char *port; @@ -15,6 +18,7 @@ typedef struct { mp_thresholds offset_thresholds; bool output_format_is_set; + long poll_delay; mp_output_format output_format; } check_ntp_time_config; @@ -29,6 +33,7 @@ check_ntp_time_config check_ntp_time_config_init() { .offset_thresholds = mp_thresholds_init(), .output_format_is_set = false, + .poll_delay = default_polling_delay, }; mp_range warning = mp_range_init(); -- cgit v1.2.3-74-g34f1