mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-06-11 01:30:00 -04:00
Check ntp time delay (#2277)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
* 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 <lorenz@vulgrim.de> * 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 <lorenz@vulgrim.de> --------- Co-authored-by: Paul Crawford <paul@crawford-space.co.uk> Co-authored-by: Lorenz Kästle <lorenz@vulgrim.de>
This commit is contained in:
parent
cc8d5b55de
commit
1372654e8a
2 changed files with 10 additions and 1 deletions
|
|
@ -43,6 +43,7 @@
|
|||
#include "thresholds.h"
|
||||
#include "check_ntp_time.d/config.h"
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
static int verbose = 0;
|
||||
|
|
@ -395,7 +396,10 @@ static offset_request_wrapper offset_request(const char *host, const char *port,
|
|||
.sun_family = AF_UNIX,
|
||||
};
|
||||
|
||||
strncpy(unix_socket.sun_path, host, strlen(host));
|
||||
if (strlen(host) > sizeof(unix_socket.sun_path)) {
|
||||
die(STATE_UNKNOWN, "host argument is too long (%lu) for a socket path\n", strlen(host));
|
||||
}
|
||||
strncpy(unix_socket.sun_path, host, sizeof(unix_socket.sun_path));
|
||||
|
||||
if (connect(socklist[0], &unix_socket, sizeof(unix_socket))) {
|
||||
/* don't die here, because it is enough if there is one server
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
#include "thresholds.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/* 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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue