diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_ntp_peer.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index e0913add..edef66a8 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c | |||
@@ -228,7 +228,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji | |||
228 | ntp_assoc_status_pair *peers=NULL; | 228 | ntp_assoc_status_pair *peers=NULL; |
229 | ntp_control_message req; | 229 | ntp_control_message req; |
230 | const char *getvar = "stratum,offset,jitter"; | 230 | const char *getvar = "stratum,offset,jitter"; |
231 | char *data=NULL, *value=NULL, *nptr=NULL; | 231 | char *data, *value, *nptr; |
232 | void *tmp; | 232 | void *tmp; |
233 | 233 | ||
234 | status = STATE_OK; | 234 | status = STATE_OK; |
@@ -350,6 +350,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji | |||
350 | printf("parsing offset from peer %.2x: ", ntohs(peers[i].assoc)); | 350 | printf("parsing offset from peer %.2x: ", ntohs(peers[i].assoc)); |
351 | 351 | ||
352 | value = extract_value(data, "offset"); | 352 | value = extract_value(data, "offset"); |
353 | nptr=NULL; | ||
353 | /* Convert the value if we have one */ | 354 | /* Convert the value if we have one */ |
354 | if(value != NULL) | 355 | if(value != NULL) |
355 | tmp_offset = strtod(value, &nptr) / 1000; | 356 | tmp_offset = strtod(value, &nptr) / 1000; |
@@ -373,12 +374,13 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji | |||
373 | printf("parsing %s from peer %.2x: ", strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter", ntohs(peers[i].assoc)); | 374 | printf("parsing %s from peer %.2x: ", strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter", ntohs(peers[i].assoc)); |
374 | } | 375 | } |
375 | value = extract_value(data, strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter"); | 376 | value = extract_value(data, strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter"); |
377 | nptr=NULL; | ||
376 | /* Convert the value if we have one */ | 378 | /* Convert the value if we have one */ |
377 | if(value != NULL) | 379 | if(value != NULL) |
378 | *jitter = strtod(value, &nptr); | 380 | *jitter = strtod(value, &nptr); |
379 | /* If value is null or no conversion was performed */ | 381 | /* If value is null or no conversion was performed */ |
380 | if(value == NULL || value==nptr){ | 382 | if(value == NULL || value==nptr){ |
381 | if(verbose) printf("error: unable to read server jitter response.\n"); | 383 | if(verbose) printf("error: unable to read server jitter/dispersion response.\n"); |
382 | *jitter = -1; | 384 | *jitter = -1; |
383 | } else { | 385 | } else { |
384 | if(verbose) printf("%g\n", *jitter); | 386 | if(verbose) printf("%g\n", *jitter); |
@@ -391,6 +393,8 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji | |||
391 | printf("parsing stratum from peer %.2x: ", ntohs(peers[i].assoc)); | 393 | printf("parsing stratum from peer %.2x: ", ntohs(peers[i].assoc)); |
392 | } | 394 | } |
393 | value = extract_value(data, "stratum"); | 395 | value = extract_value(data, "stratum"); |
396 | nptr=NULL; | ||
397 | /* Convert the value if we have one */ | ||
394 | if(value != NULL) | 398 | if(value != NULL) |
395 | *stratum = strtol(value, &nptr, 10); | 399 | *stratum = strtol(value, &nptr, 10); |
396 | if(value == NULL || value==nptr){ | 400 | if(value == NULL || value==nptr){ |