diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-09-26 04:16:21 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-09-26 04:16:21 (GMT) |
commit | 0b66867288b1eb9b9c7a2ffa5cf5e3fd473dc1e7 (patch) | |
tree | 2b7b438c5f31ec38f74549b553a8b89032a01cd8 /plugins/check_ntp.c | |
parent | e6d1efc69ee396d0f37fb7b57055b6df07c554ad (diff) | |
download | monitoring-plugins-0b66867288b1eb9b9c7a2ffa5cf5e3fd473dc1e7.tar.gz |
Patch #1798774: check_ntp: honor ntp flags
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1799 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ntp.c')
-rw-r--r-- | plugins/check_ntp.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 28c23d8..abd254c 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c | |||
@@ -86,6 +86,7 @@ typedef struct { | |||
86 | double rtdelay; /* converted from the ntp_message */ | 86 | double rtdelay; /* converted from the ntp_message */ |
87 | double rtdisp; /* converted from the ntp_message */ | 87 | double rtdisp; /* converted from the ntp_message */ |
88 | double offset[AVG_NUM]; /* offsets from each response */ | 88 | double offset[AVG_NUM]; /* offsets from each response */ |
89 | uint8_t flags; /* byte with leapindicator,vers,mode. see macros */ | ||
89 | } ntp_server_results; | 90 | } ntp_server_results; |
90 | 91 | ||
91 | /* this structure holds everything in an ntp control message as per rfc1305 */ | 92 | /* this structure holds everything in an ntp control message as per rfc1305 */ |
@@ -302,6 +303,12 @@ int best_offset_server(const ntp_server_results *slist, int nservers){ | |||
302 | 303 | ||
303 | /* for each server */ | 304 | /* for each server */ |
304 | for(cserver=0; cserver<nservers; cserver++){ | 305 | for(cserver=0; cserver<nservers; cserver++){ |
306 | /* sort out servers with error flags */ | ||
307 | if ( LI(slist[cserver].flags) != LI_NOWARNING ){ | ||
308 | if (verbose) printf("discarding peer id %d: flags=%d\n", cserver, LI(slist[cserver].flags)); | ||
309 | break; | ||
310 | } | ||
311 | |||
305 | /* compare it to each of the servers already in the candidate list */ | 312 | /* compare it to each of the servers already in the candidate list */ |
306 | for(i=0; i<csize; i++){ | 313 | for(i=0; i<csize; i++){ |
307 | /* does it have an equal or better stratum? */ | 314 | /* does it have an equal or better stratum? */ |
@@ -450,6 +457,7 @@ double offset_request(const char *host, int *status){ | |||
450 | servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp); | 457 | servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp); |
451 | servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay); | 458 | servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay); |
452 | servers[i].waiting=0; | 459 | servers[i].waiting=0; |
460 | servers[i].flags=req[i].flags; | ||
453 | servers_readable--; | 461 | servers_readable--; |
454 | one_read = 1; | 462 | one_read = 1; |
455 | if(servers[i].num_responses==AVG_NUM) servers_completed++; | 463 | if(servers[i].num_responses==AVG_NUM) servers_completed++; |
@@ -808,6 +816,7 @@ int main(int argc, char *argv[]){ | |||
808 | } | 816 | } |
809 | if(offset_result==STATE_CRITICAL){ | 817 | if(offset_result==STATE_CRITICAL){ |
810 | asprintf(&result_line, "%s %s", result_line, _("Offset unknown")); | 818 | asprintf(&result_line, "%s %s", result_line, _("Offset unknown")); |
819 | asprintf(&perfdata_line, ""); | ||
811 | } else { | 820 | } else { |
812 | if(offset_result==STATE_WARNING){ | 821 | if(offset_result==STATE_WARNING){ |
813 | asprintf(&result_line, "%s %s", result_line, _("Unable to fully sample sync server")); | 822 | asprintf(&result_line, "%s %s", result_line, _("Unable to fully sample sync server")); |