Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check_dig: stick with integer devision
This change saves us from having to link check_dig against "libm"
- Loading branch information
e33ecc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holger made a good point about this change:
nagios-plugins/nagios-plugins@05a63d8
ceil may be more correct as the plugin will still alarm once it reaches the global timeout value.
e33ecc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we're using
timeout_interval / number_tries + number_tries
(while your interim solution didn't addnumber_tries
to the result). Yes, the results will often be, err, "less correct" compared to the floating point division, but I think this might be good enough for us. Especially as we didn't add a fancy--retries
flag like you did :-)But thanks for the hint!
e33ecc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long long timeout_interval_ll = (timeout_interval<<8);
timeout_interval_ll = timeout_interval_ll / ( number_tries<<8);
int timeout_interval_dig = (timeout_interval_lg >>8) + number_tries;
e33ecc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, thanks, but personally I'd strongly prefer the floating point division then :-P
e33ecc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be good enough, but most timeout values other than those that produce 0 from the division (less than 3) will cause dig to only timeout twice with the patch. I think the disagreement is philosophical at this point: I would rather allow the user to control the behavior - if they have a slow server or an intermittent one, they may wish for more retries etc. So we will stick with floating point division, though this does work just fine as well and escapes having to pull in the math libraries.
Cheers all.
@willix. no bitwise thank you, though it is clever :)
e33ecc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I was inclined to hardcode
+tries=1
on thedig(1)
command line. While thedig(1)
command happens to implement retries by default, most of our plugins don't, because users might want to notice if some fraction of queries fail, and because Nagios & friends support "soft states" if users don't want to be notified in such cases. I'd be surprised if the originalcheck_dig
author consciously relied on thesedig(1)
semantics.And yes, maybe the disagreement is "philosophical": I do not at all believe that more configuration switches are necessarily better. Only those that might actually be useful are good :-) But I'll agree that there are many cases where you could argue one way or the other.
Either way, if there's just one more comment on this single line of code, I'll revert to the floating point division, which I agree is totally fine as well ;-)
e33ecc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still love each all! ;)