aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--plugins/check_ntp.c63
2 files changed, 10 insertions, 54 deletions
diff --git a/NEWS b/NEWS
index 7a7ef8c0..0c26c825 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,6 @@ This file documents the major additions and syntax changes between releases.
1.4.11 or 1.5 ??
Fix check_http regression in 1.4.10 where following redirects to
relative URLs on virtual hosts failed if both "-H" and "-I" were used
- Add stratum thresholds support to check_ntp (feature request #1703823)
check_ntp now return UNKNOWN instead of WARNING if jitter is unavailable (jitter=-1.000000)
as long as the thresholds range inculde -1. If no offset threshold is specified
and the offset is unavailable, will return UNKNOWN as well.
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 28541616..38562ac9 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -50,9 +50,6 @@ static int verbose=0;
static short do_offset=0;
static char *owarn="60";
static char *ocrit="120";
-static short do_stratum=0;
-static char *swarn="16";
-static char *scrit="16";
static short do_jitter=0;
static char *jwarn="5000";
static char *jcrit="10000";
@@ -60,7 +57,6 @@ static char *jcrit="10000";
int process_arguments (int, char **);
thresholds *offset_thresholds = NULL;
thresholds *jitter_thresholds = NULL;
-thresholds *stratum_thresholds = NULL;
void print_help (void);
void print_usage (void);
@@ -361,7 +357,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
* we don't waste time sitting around waiting for single packets.
* - we also "manually" handle resolving host names and connecting, because
* we have to do it in a way that our lazy macros don't handle currently :( */
-double offset_request(const char *host, int *stratum, int *status){
+double offset_request(const char *host, int *status){
int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
time_t now_time=0, start_ts=0;
@@ -458,7 +454,7 @@ double offset_request(const char *host, int *stratum, int *status){
respnum=servers[i].num_responses++;
servers[i].offset[respnum]=calc_offset(&req[i], &recv_time);
if(verbose) {
- printf("offset %.10g, stratum %i\n", servers[i].offset[respnum], req[i].stratum);
+ printf("offset %.10g\n", servers[i].offset[respnum]);
}
servers[i].stratum=req[i].stratum;
servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp);
@@ -487,9 +483,6 @@ double offset_request(const char *host, int *stratum, int *status){
avg_offset+=servers[best_index].offset[j];
}
avg_offset/=servers[best_index].num_responses;
- /* Stratum sent in normal packets is ingreased by 1 (i.e. stratum that
- * would be displayed if we were a server) so we decrease it */
- *stratum = servers[best_index].stratum - 1;
}
/* cleanup */
@@ -667,8 +660,6 @@ int process_arguments(int argc, char **argv){
{"use-ipv6", no_argument, 0, '6'},
{"warning", required_argument, 0, 'w'},
{"critical", required_argument, 0, 'c'},
- {"swarn", required_argument, 0, 'W'},
- {"scrit", required_argument, 0, 'C'},
{"jwarn", required_argument, 0, 'j'},
{"jcrit", required_argument, 0, 'k'},
{"timeout", required_argument, 0, 't'},
@@ -681,7 +672,7 @@ int process_arguments(int argc, char **argv){
usage ("\n");
while (1) {
- c = getopt_long (argc, argv, "Vhv46w:c:W:C:j:k:t:H:", longopts, &option);
+ c = getopt_long (argc, argv, "Vhv46w:c:j:k:t:H:", longopts, &option);
if (c == -1 || c == EOF || c == 1)
break;
@@ -705,14 +696,6 @@ int process_arguments(int argc, char **argv){
do_offset=1;
ocrit = optarg;
break;
- case 'W':
- do_stratum=1;
- swarn = optarg;
- break;
- case 'C':
- do_stratum=1;
- scrit = optarg;
- break;
case 'j':
do_jitter=1;
jwarn = optarg;
@@ -769,16 +752,8 @@ char *perfd_jitter (double jitter)
TRUE, 0, FALSE, 0);
}
-char *perfd_stratum (int stratum)
-{
- return perfdata ("stratum", stratum, "",
- do_stratum, (int)stratum_thresholds->warning->end,
- do_stratum, (int)stratum_thresholds->critical->end,
- TRUE, 0, TRUE, 16);
-}
-
int main(int argc, char *argv[]){
- int result, offset_result, jitter_result, stratum;
+ int result, offset_result, jitter_result;
double offset=0, jitter=0;
char *result_line, *perfdata_line;
@@ -789,7 +764,6 @@ int main(int argc, char *argv[]){
set_thresholds(&offset_thresholds, owarn, ocrit);
set_thresholds(&jitter_thresholds, jwarn, jcrit);
- set_thresholds(&stratum_thresholds, swarn, scrit);
/* initialize alarm signal handling */
signal (SIGALRM, socket_timeout_alarm_handler);
@@ -797,15 +771,14 @@ int main(int argc, char *argv[]){
/* set socket timeout */
alarm (socket_timeout);
- offset = offset_request(server_address, &stratum, &offset_result);
+ offset = offset_request(server_address, &offset_result);
+ /* check_ntp used to always return if offset_result == STATE_UNKNOWN.
+ * Now we'll only do that is the offset thresholds were set */
if (do_offset && offset_result == STATE_UNKNOWN) {
result = STATE_CRITICAL;
} else {
result = get_status(fabs(offset), offset_thresholds);
}
- result = max_state(result, offset_result);
- if(do_stratum)
- result = max_state(result, get_status(stratum, stratum_thresholds));
/* If not told to check the jitter, we don't even send packets.
* jitter is checked using NTP control packets, which not all
@@ -814,13 +787,13 @@ int main(int argc, char *argv[]){
*/
if(do_jitter){
jitter=jitter_request(server_address, &jitter_result);
- result = max_state(result, get_status(jitter, jitter_thresholds));
+ result = max_state_alt(result, get_status(jitter, jitter_thresholds));
/* -1 indicates that we couldn't calculate the jitter
* Only overrides STATE_OK from the offset */
if(jitter == -1.0 && result == STATE_OK)
result = STATE_UNKNOWN;
}
- result = max_state(result, jitter_result);
+ result = max_state_alt(result, jitter_result);
switch (result) {
case STATE_CRITICAL :
@@ -840,11 +813,6 @@ int main(int argc, char *argv[]){
asprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
asprintf(&perfdata_line, "");
} else {
-#if 0 /* 2007-10-25 This can't happen. Leftovers or uninplemented? */
- if(offset_result==STATE_WARNING){
- asprintf(&result_line, "%s %s", result_line, _("Unable to fully sample sync server"));
- }
-#endif
asprintf(&result_line, "%s Offset %.10g secs", result_line, offset);
asprintf(&perfdata_line, "%s", perfd_offset(offset));
}
@@ -852,10 +820,6 @@ int main(int argc, char *argv[]){
asprintf(&result_line, "%s, jitter=%f", result_line, jitter);
asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
}
- if (do_stratum) {
- asprintf(&result_line, "%s, stratum=%i", result_line, stratum);
- asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
- }
printf("%s|%s\n", result_line, perfdata_line);
if(server_address!=NULL) free(server_address);
@@ -881,10 +845,6 @@ void print_help(void){
printf (" %s\n", _("Offset to result in warning status (seconds)"));
printf (" %s\n", "-c, --critical=THRESHOLD");
printf (" %s\n", _("Offset to result in critical status (seconds)"));
- printf (" %s\n", "-W, --warning=THRESHOLD");
- printf (" %s\n", _("Warning threshold for stratum"));
- printf (" %s\n", "-W, --critical=THRESHOLD");
- printf (" %s\n", _("Critical threshold for stratum"));
printf (" %s\n", "-j, --warning=THRESHOLD");
printf (" %s\n", _("Warning threshold for jitter"));
printf (" %s\n", "-k, --critical=THRESHOLD");
@@ -905,8 +865,6 @@ void print_help(void){
printf(" %s\n", _("Check jitter too, avoiding critical notifications if jitter isn't available"));
printf(" %s\n", _("(See Notes above for more details on thresholds formats):"));
printf(" %s\n", ("./check_ntp -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200"));
- printf(" %s\n", _("Check only stratum:"));
- printf(" %s\n", ("./check_ntp -H ntpserv -W 4 -C 6"));
printf (_(UT_SUPPORT));
}
@@ -915,6 +873,5 @@ void
print_usage(void)
{
printf (_("Usage:"));
- printf(" %s -H <host> [-w <warn>] [-c <crit>] [-W <warn>] [-C <crit>]\n", progname);
- printf(" [-j <warn>] [-k <crit>] [-v verbose]\n");
+ printf(" %s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n", progname);
}