summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 56e5a05..5037786 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -183,6 +183,32 @@ void setup_request(ntp_message *p){
183 TVtoNTP64(t,p->txts); 183 TVtoNTP64(t,p->txts);
184} 184}
185 185
186double offset_request(const char *host){
187 int i=0, conn=-1;
188 ntp_message req;
189 double next_offset=0., avg_offset=0.;
190 struct timeval recv_time;
191
192 for(i=0; i<4; i++){
193 setup_request(&req);
194 my_udp_connect(server_address, 123, &conn);
195 write(conn, &req, sizeof(ntp_message));
196 read(conn, &req, sizeof(ntp_message));
197 gettimeofday(&recv_time, NULL);
198 /* if(verbose) print_packet(&req); */
199 close(conn);
200 next_offset=calc_offset(&req, &recv_time);
201 if(verbose) printf("offset: %g\n", next_offset);
202 avg_offset+=next_offset;
203 }
204 return avg_offset/4.;
205}
206
207/* not yet implemented yet */
208double jitter_request(const char *host){
209 return 0.;
210}
211
186int process_arguments(int argc, char **argv){ 212int process_arguments(int argc, char **argv){
187 int c; 213 int c;
188 int option=0; 214 int option=0;
@@ -282,9 +308,6 @@ int process_arguments(int argc, char **argv){
282 308
283int main(int argc, char *argv[]){ 309int main(int argc, char *argv[]){
284 int result = STATE_UNKNOWN; 310 int result = STATE_UNKNOWN;
285 int conn;
286 ntp_message m;
287 struct timeval recv_time;
288 double offset=0, jitter=0; 311 double offset=0, jitter=0;
289 312
290 if (process_arguments (argc, argv) == ERROR) 313 if (process_arguments (argc, argv) == ERROR)
@@ -296,18 +319,7 @@ int main(int argc, char *argv[]){
296 /* set socket timeout */ 319 /* set socket timeout */
297 alarm (socket_timeout); 320 alarm (socket_timeout);
298 321
299 setup_request(&m); 322 offset = offset_request(server_address);
300 if(verbose) print_packet(&m);
301 my_udp_connect(server_address, 123, &conn);
302 write(conn, &m, sizeof(ntp_message));
303 read(conn, &m, sizeof(ntp_message));
304 gettimeofday(&recv_time, NULL);
305 if(verbose) print_packet(&m);
306 close(conn);
307
308 offset=calc_offset(&m, &recv_time);
309 printf("total offset: %g\n", offset);
310
311 if(offset > ocrit){ 323 if(offset > ocrit){
312 printf("NTP CRITICAL: "); 324 printf("NTP CRITICAL: ");
313 result = STATE_CRITICAL; 325 result = STATE_CRITICAL;
@@ -319,14 +331,15 @@ int main(int argc, char *argv[]){
319 result = STATE_OK; 331 result = STATE_OK;
320 } 332 }
321 333
322 /* not implemented yet: 334 /* not implemented yet: */
323 jitter=calc_jitter(&m, &recv_time); 335 jitter=jitter_request(server_address);
324 336
337 /* not implemented yet:
325 if(do_jitter){ 338 if(do_jitter){
326 if(offset > ocrit){ 339 if(jitter > jcrit){
327 printf("NTP CRITICAL: "); 340 printf("NTP CRITICAL: ");
328 result = STATE_CRITICAL; 341 result = STATE_CRITICAL;
329 } else if(offset > owarn) { 342 } else if(jitter > jwarn) {
330 printf("NTP WARNING: "); 343 printf("NTP WARNING: ");
331 result = STATE_WARNING; 344 result = STATE_WARNING;
332 } else { 345 } else {