Ver Fonte

check_ntp_time: Bug in average calculation fixed. Thanks to waja and Larsi

abrist há 12 anos atrás
pai
commit
ec8c777140
1 ficheiros alterados com 3 adições e 1 exclusões
  1. 3 1
      plugins/check_ntp.c

+ 3 - 1
plugins/check_ntp.c

@@ -54,7 +54,9 @@ void print_help (void);
 void print_usage (void);
 
 /* number of times to perform each request to get a good average. */
+#ifndef AVG_NUM
 #define AVG_NUM 4
+#endif
 
 /* max size of control message data */
 #define MAX_CM_SIZE 468
@@ -480,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;
 	}