Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check_ntp_time: Bug in average calculation [sf#2993229] #956

Closed
monitoring-user opened this issue Sep 24, 2013 · 0 comments
Closed

check_ntp_time: Bug in average calculation [sf#2993229] #956

monitoring-user opened this issue Sep 24, 2013 · 0 comments

Comments

@monitoring-user
Copy link

Submitted by larsi- on 2010-04-27 23:08:10

Hello Nagios-Plugins Team,

attached you can find a patch which applies to current check_ntp_time. The bug was found by Mathias Kettner.

The patch contains the following changes:

  1. A minor change which makes the AVG_NUM configurable by compiler define.
  2. The more important change: A fix for a bug which caused the 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.

Kind regards,
Lars

--- check_ntp_time.c.orig 2010-04-27 12:08:08.000000000 +0000
+++ check_ntp_time.c 2010-04-27 12:13:23.000000000 +0000
@@ -55,7 +55,9 @@
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
@@ -422,7 +424,7 @@
} 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;
    
    }
waja added a commit to waja/monitoring-plugins that referenced this issue Sep 30, 2013
Just turning attached patch of github issue monitoring-plugins#956 into a push request
@ghost ghost assigned waja Jan 24, 2014
waja added a commit to waja/monitoring-plugins that referenced this issue Jan 24, 2014
1. A minor change which makes the AVG_NUM configurable by compiler define.
2. 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.

(Closes: monitoring-plugins#956)
(Closes: monitoring-plugins#1089)
(Closes: monitoring-plugins#1166)
waja added a commit to waja/monitoring-plugins that referenced this issue Jan 24, 2014
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 monitoring-plugins#956 and Closes monitoring-plugins#1166
Closes: monitoring-plugins#1089
@waja waja closed this as completed in c5dc81c Jan 24, 2014
@waja waja removed their assignment Oct 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants