mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-06-11 01:30:00 -04:00
Small cleanups
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/dermoth_ntp_rework@1839 f882894a-f735-0410-b71e-b25c423dba1c
This commit is contained in:
parent
20470f273a
commit
6157cdf6e5
1 changed files with 6 additions and 2 deletions
|
|
@ -228,7 +228,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
|
|||
ntp_assoc_status_pair *peers=NULL;
|
||||
ntp_control_message req;
|
||||
const char *getvar = "stratum,offset,jitter";
|
||||
char *data=NULL, *value=NULL, *nptr=NULL;
|
||||
char *data, *value, *nptr;
|
||||
void *tmp;
|
||||
|
||||
status = STATE_OK;
|
||||
|
|
@ -350,6 +350,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
|
|||
printf("parsing offset from peer %.2x: ", ntohs(peers[i].assoc));
|
||||
|
||||
value = extract_value(data, "offset");
|
||||
nptr=NULL;
|
||||
/* Convert the value if we have one */
|
||||
if(value != NULL)
|
||||
tmp_offset = strtod(value, &nptr) / 1000;
|
||||
|
|
@ -373,12 +374,13 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
|
|||
printf("parsing %s from peer %.2x: ", strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter", ntohs(peers[i].assoc));
|
||||
}
|
||||
value = extract_value(data, strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter");
|
||||
nptr=NULL;
|
||||
/* Convert the value if we have one */
|
||||
if(value != NULL)
|
||||
*jitter = strtod(value, &nptr);
|
||||
/* If value is null or no conversion was performed */
|
||||
if(value == NULL || value==nptr){
|
||||
if(verbose) printf("error: unable to read server jitter response.\n");
|
||||
if(verbose) printf("error: unable to read server jitter/dispersion response.\n");
|
||||
*jitter = -1;
|
||||
} else {
|
||||
if(verbose) printf("%g\n", *jitter);
|
||||
|
|
@ -391,6 +393,8 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
|
|||
printf("parsing stratum from peer %.2x: ", ntohs(peers[i].assoc));
|
||||
}
|
||||
value = extract_value(data, "stratum");
|
||||
nptr=NULL;
|
||||
/* Convert the value if we have one */
|
||||
if(value != NULL)
|
||||
*stratum = strtol(value, &nptr, 10);
|
||||
if(value == NULL || value==nptr){
|
||||
|
|
|
|||
Loading…
Reference in a new issue