Jelajahi Sumber

Fixing bug in average calculation (Submitted by Lars)

The more important change: A fix for a bug which caused the check_ntp_time
and check_ntp_time check to always take the first response from ntp and not
the avarage since "j" is not increased anywhere. "i" should be used there
instead.

Partly Closes #956 and Closes #1166
Closes: #1089
Jan Wagner 12 tahun lalu
induk
melakukan
ccecba33a2
2 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 1 1
      plugins/check_ntp.c
  2. 1 1
      plugins/check_ntp_time.c

+ 1 - 1
plugins/check_ntp.c

@@ -482,7 +482,7 @@ double offset_request(const char *host, int *status){
 	} else {
 		/* finally, calculate the average offset */
 		for(i=0; i<servers[best_index].num_responses;i++){
-			avg_offset+=servers[best_index].offset[j];
+			avg_offset+=servers[best_index].offset[i];
 		}
 		avg_offset/=servers[best_index].num_responses;
 	}

+ 1 - 1
plugins/check_ntp_time.c

@@ -428,7 +428,7 @@ double offset_request(const char *host, int *status){
 	} else {
 		/* finally, calculate the average offset */
 		for(i=0; i<servers[best_index].num_responses;i++){
-			avg_offset+=servers[best_index].offset[j];
+			avg_offset+=servers[best_index].offset[i];
 		}
 		avg_offset/=servers[best_index].num_responses;
 	}