|
@@ -10,7 +10,7 @@
|
|
|
*
|
|
*
|
|
|
* This file contains the check_ntp plugin
|
|
* This file contains the check_ntp plugin
|
|
|
*
|
|
*
|
|
|
-* This plugin to check ntp servers independant of any commandline
|
|
|
|
|
|
|
+* This plugin to check ntp servers independent of any commandline
|
|
|
* programs or external libraries.
|
|
* programs or external libraries.
|
|
|
*
|
|
*
|
|
|
*
|
|
*
|
|
@@ -79,7 +79,7 @@ typedef struct {
|
|
|
/* this structure holds data about results from querying offset from a peer */
|
|
/* this structure holds data about results from querying offset from a peer */
|
|
|
typedef struct {
|
|
typedef struct {
|
|
|
time_t waiting; /* ts set when we started waiting for a response */
|
|
time_t waiting; /* ts set when we started waiting for a response */
|
|
|
- int num_responses; /* number of successfully recieved responses */
|
|
|
|
|
|
|
+ int num_responses; /* number of successfully received responses */
|
|
|
uint8_t stratum; /* copied verbatim from the ntp_message */
|
|
uint8_t stratum; /* copied verbatim from the ntp_message */
|
|
|
double rtdelay; /* converted from the ntp_message */
|
|
double rtdelay; /* converted from the ntp_message */
|
|
|
double rtdisp; /* converted from the ntp_message */
|
|
double rtdisp; /* converted from the ntp_message */
|
|
@@ -100,7 +100,7 @@ typedef struct {
|
|
|
/* NB: not necessarily NULL terminated! */
|
|
/* NB: not necessarily NULL terminated! */
|
|
|
} ntp_control_message;
|
|
} ntp_control_message;
|
|
|
|
|
|
|
|
-/* this is an association/status-word pair found in control packet reponses */
|
|
|
|
|
|
|
+/* this is an association/status-word pair found in control packet responses */
|
|
|
typedef struct {
|
|
typedef struct {
|
|
|
uint16_t assoc;
|
|
uint16_t assoc;
|
|
|
uint16_t status;
|
|
uint16_t status;
|
|
@@ -548,7 +548,7 @@ double jitter_request(const char *host, int *status){
|
|
|
DBG(print_ntp_control_message(&req));
|
|
DBG(print_ntp_control_message(&req));
|
|
|
/* Attempt to read the largest size packet possible */
|
|
/* Attempt to read the largest size packet possible */
|
|
|
req.count=htons(MAX_CM_SIZE);
|
|
req.count=htons(MAX_CM_SIZE);
|
|
|
- DBG(printf("recieving READSTAT response"))
|
|
|
|
|
|
|
+ DBG(printf("receiving READSTAT response"))
|
|
|
read(conn, &req, SIZEOF_NTPCM(req));
|
|
read(conn, &req, SIZEOF_NTPCM(req));
|
|
|
DBG(print_ntp_control_message(&req));
|
|
DBG(print_ntp_control_message(&req));
|
|
|
/* Each peer identifier is 4 bytes in the data section, which
|
|
/* Each peer identifier is 4 bytes in the data section, which
|
|
@@ -575,7 +575,7 @@ double jitter_request(const char *host, int *status){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(verbose) printf("%d candiate peers available\n", num_candidates);
|
|
|
|
|
|
|
+ if(verbose) printf("%d candidate peers available\n", num_candidates);
|
|
|
if(verbose && syncsource_found) printf("synchronization source found\n");
|
|
if(verbose && syncsource_found) printf("synchronization source found\n");
|
|
|
if(! syncsource_found){
|
|
if(! syncsource_found){
|
|
|
*status = STATE_UNKNOWN;
|
|
*status = STATE_UNKNOWN;
|
|
@@ -597,7 +597,7 @@ double jitter_request(const char *host, int *status){
|
|
|
/* By spec, putting the variable name "jitter" in the request
|
|
/* By spec, putting the variable name "jitter" in the request
|
|
|
* should cause the server to provide _only_ the jitter value.
|
|
* should cause the server to provide _only_ the jitter value.
|
|
|
* thus reducing net traffic, guaranteeing us only a single
|
|
* thus reducing net traffic, guaranteeing us only a single
|
|
|
- * datagram in reply, and making intepretation much simpler
|
|
|
|
|
|
|
+ * datagram in reply, and making interpretation much simpler
|
|
|
*/
|
|
*/
|
|
|
/* Older servers doesn't know what jitter is, so if we get an
|
|
/* Older servers doesn't know what jitter is, so if we get an
|
|
|
* error on the first pass we redo it with "dispersion" */
|
|
* error on the first pass we redo it with "dispersion" */
|
|
@@ -608,7 +608,7 @@ double jitter_request(const char *host, int *status){
|
|
|
DBG(print_ntp_control_message(&req));
|
|
DBG(print_ntp_control_message(&req));
|
|
|
|
|
|
|
|
req.count = htons(MAX_CM_SIZE);
|
|
req.count = htons(MAX_CM_SIZE);
|
|
|
- DBG(printf("recieving READVAR response...\n"));
|
|
|
|
|
|
|
+ DBG(printf("receiving READVAR response...\n"));
|
|
|
read(conn, &req, SIZEOF_NTPCM(req));
|
|
read(conn, &req, SIZEOF_NTPCM(req));
|
|
|
DBG(print_ntp_control_message(&req));
|
|
DBG(print_ntp_control_message(&req));
|
|
|
|
|
|