author | Corey Kosak <kosak@google.com> | |
Fri, 22 Jan 2016 21:56:37 +0000 (16:56 -0500) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Tue, 26 Jan 2016 06:15:54 +0000 (07:15 +0100) | ||
commit | f1552fdc8b98860f22e69d162db295bfb9b49180 | |
tree | 864888424d1096c9ac05c3960ba1a22ec59fe1de | tree | snapshot |
parent | d5565943cd7ee338e5b750a027faff8115df4c72 | commit | diff |
Don't divide by 0 when doing percentages (e.g. with the swap plugin).
Prior to this change, if all the values being sent sum to zero, then the
calculated percentage is a division by 0 which is either Inf or NaN
depending on the numerator.
This is not a theoretical concern: it can easily happen if all the input
gauges are 0.
This change forces the output to be zero if the denominator is zero.
Prior to this change, if all the values being sent sum to zero, then the
calculated percentage is a division by 0 which is either Inf or NaN
depending on the numerator.
This is not a theoretical concern: it can easily happen if all the input
gauges are 0.
This change forces the output to be zero if the denominator is zero.
src/daemon/plugin.c | diff | blob | history |