diff options
author | Jan Wagner <waja@cyconet.org> | 2014-01-24 18:20:08 +0100 |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2014-01-24 18:20:08 +0100 |
commit | ccecba33a2b32e607b2d008a69a90f6532926374 (patch) | |
tree | 6aaac23a758d28285a8b6d98836d85ba9d184db7 | |
parent | c5dc81cd2889421115b4d33b959b0ff8e2df9f6c (diff) | |
download | monitoring-plugins-ccecba3.tar.gz |
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
-rw-r--r-- | plugins/check_ntp.c | 2 | ||||
-rw-r--r-- | 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 6607b4b4..0a7640a7 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c | |||
@@ -482,7 +482,7 @@ double offset_request(const char *host, int *status){ | |||
482 | } else { | 482 | } else { |
483 | /* finally, calculate the average offset */ | 483 | /* finally, calculate the average offset */ |
484 | for(i=0; i<servers[best_index].num_responses;i++){ | 484 | for(i=0; i<servers[best_index].num_responses;i++){ |
485 | avg_offset+=servers[best_index].offset[j]; | 485 | avg_offset+=servers[best_index].offset[i]; |
486 | } | 486 | } |
487 | avg_offset/=servers[best_index].num_responses; | 487 | avg_offset/=servers[best_index].num_responses; |
488 | } | 488 | } |
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index f8564571..72dffbd8 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){ | |||
428 | } else { | 428 | } else { |
429 | /* finally, calculate the average offset */ | 429 | /* finally, calculate the average offset */ |
430 | for(i=0; i<servers[best_index].num_responses;i++){ | 430 | for(i=0; i<servers[best_index].num_responses;i++){ |
431 | avg_offset+=servers[best_index].offset[j]; | 431 | avg_offset+=servers[best_index].offset[i]; |
432 | } | 432 | } |
433 | avg_offset/=servers[best_index].num_responses; | 433 | avg_offset/=servers[best_index].num_responses; |
434 | } | 434 | } |