[monitoring-plugins] Fixing bug in average calculation (Submitted by ...

Git Repository git at monitoring-plugins.org
Fri Jan 24 18:30:07 CET 2014


 Module: monitoring-plugins
 Branch: master
 Commit: ccecba33a2b32e607b2d008a69a90f6532926374
 Author: Jan Wagner <waja at cyconet.org>
   Date: Fri Jan 24 18:20:08 2014 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ccecba3

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

---

 plugins/check_ntp.c      | 2 +-
 plugins/check_ntp_time.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 6607b4b..0a7640a 100644
--- a/plugins/check_ntp.c
+++ b/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;
 	}
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index f856457..72dffbd 100644
--- a/plugins/check_ntp_time.c
+++ b/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;
 	}



More information about the Commits mailing list