diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-04-04 20:08:59 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-04-04 20:08:59 +0000 |
commit | cff02b30d52c219727fb4522517fbf66434bc577 (patch) | |
tree | abb065d8893c21871a264cf9d37c197f6861dfbb /plugins/check_ntp.c | |
parent | b19f0704f31e0a7cd2d1302e964efa2b038cfae7 (diff) | |
download | monitoring-plugins-cff02b30d52c219727fb4522517fbf66434bc577.tar.gz |
Fix for getting dispersion instead of jitter on older servers (like xntpd on Solaris).
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1676 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ntp.c')
-rw-r--r-- | plugins/check_ntp.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 30e58900..18571184 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c @@ -507,6 +507,7 @@ double jitter_request(const char *host, int *status){ int peers_size=0, peer_offset=0; ntp_assoc_status_pair *peers=NULL; ntp_control_message req; + const char *getvar = "jitter"; double rval = 0.0, jitter = -1.0; char *startofvalue=NULL, *nptr=NULL; void *tmp; @@ -584,8 +585,10 @@ double jitter_request(const char *host, int *status){ * thus reducing net traffic, guaranteeing us only a single * datagram in reply, and making intepretation much simpler */ - strncpy(req.data, "jitter", 6); - req.count = htons(6); + /* Older servers doesn't know what jitter is, so if we get an + * error on the first pass we redo it with "dispersion" */ + strncpy(req.data, getvar, MAX_CM_SIZE-1); + req.count = htons(strlen(getvar)); DBG(printf("sending READVAR request...\n")); write(conn, &req, SIZEOF_NTPCM(req)); DBG(print_ntp_control_message(&req)); @@ -595,6 +598,14 @@ double jitter_request(const char *host, int *status){ read(conn, &req, SIZEOF_NTPCM(req)); DBG(print_ntp_control_message(&req)); + if(req.op&REM_ERROR && strstr(getvar, "jitter")) { + if(verbose) printf("The 'jitter' command failed (old ntp server?)\nRestarting with 'dispersion'...\n"); + getvar = "dispersion"; + num_selected--; + i--; + continue; + } + /* get to the float value */ if(verbose) { printf("parsing jitter from peer %.2x: ", ntohs(peers[i].assoc)); |