summaryrefslogtreecommitdiffstats
path: root/web/attachments/246468-check_ntp_flags.patch
blob: e659ec51c6606272360740eebfe5570e1bb46366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
*** nagios-plugins-1.4.9/plugins/check_ntp.c	2007-04-10 09:17:18.000000000 +0200
--- nagios-plugins-1.4.9_flags/plugins/check_ntp.c	2007-09-20 15:14:54.000000000 +0200
***************
*** 86,91 ****
--- 86,92 ----
  	double rtdelay;         /* converted from the ntp_message */
  	double rtdisp;          /* converted from the ntp_message */
  	double offset[AVG_NUM]; /* offsets from each response */
+ 	uint8_t flags;       /* byte with leapindicator,vers,mode. see macros */
  } ntp_server_results;
  
  /* this structure holds everything in an ntp control message as per rfc1305 */
***************
*** 302,307 ****
--- 303,314 ----
  
  	/* for each server */
  	for(cserver=0; cserver<nservers; cserver++){
+ 		/* sort out servers with error flags */
+ 		if ( LI(slist[cserver].flags) != LI_NOWARNING ){
+ 			if (verbose) printf("discarding peer id %d: flags=%d\n", cserver, LI(slist[cserver].flags));
+ 			break;
+ 		}
+ 
  		/* compare it to each of the servers already in the candidate list */
  		for(i=0; i<csize; i++){
  			/* does it have an equal or better stratum? */
***************
*** 450,455 ****
--- 457,463 ----
  				servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp);
  				servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay);
  				servers[i].waiting=0;
+ 				servers[i].flags=req[i].flags;
  				servers_readable--;
  				one_read = 1;
  				if(servers[i].num_responses==AVG_NUM) servers_completed++;
***************
*** 808,813 ****
--- 816,822 ----
  	}
  	if(offset_result==STATE_CRITICAL){
  		asprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
+ 		asprintf(&perfdata_line, "%s", "no perfdata");
  	} else {
  		if(offset_result==STATE_WARNING){
  			asprintf(&result_line, "%s %s", result_line, _("Unable to fully sample sync server"));