Fix TM2 kbps threshold to subtract from capacity Fixes Traffic Monitor 2.0's available bandwidth threshold to subtract the parameter value from the capacity. It was incorrectly comparing the value itself.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/b29a5d5a Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/b29a5d5a Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/b29a5d5a Branch: refs/heads/master Commit: b29a5d5a8a908856c7498c2762e42142f8c4cabf Parents: cc2eae5 Author: Robert Butts <robert.o.bu...@gmail.com> Authored: Mon Oct 31 10:28:39 2016 -0600 Committer: Dave Neuman <neu...@apache.org> Committed: Mon Nov 7 12:29:08 2016 -0700 ---------------------------------------------------------------------- .../experimental/traffic_monitor/health/cache_health.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/b29a5d5a/traffic_monitor/experimental/traffic_monitor/health/cache_health.go ---------------------------------------------------------------------- diff --git a/traffic_monitor/experimental/traffic_monitor/health/cache_health.go b/traffic_monitor/experimental/traffic_monitor/health/cache_health.go index 1106f62..d4c7639 100644 --- a/traffic_monitor/experimental/traffic_monitor/health/cache_health.go +++ b/traffic_monitor/experimental/traffic_monitor/health/cache_health.go @@ -98,6 +98,11 @@ func getQueryThreshold(threshInt int64) time.Duration { return time.Duration(threshInt) * time.Millisecond } +func cacheCapacityKbps(result cache.Result) int64 { + kbpsInMbps := int64(1000) + return int64(result.Astats.System.InfSpeed) * kbpsInMbps +} + // EvalCache returns whether the given cache should be marked available, and a string describing why func EvalCache(result cache.Result, mc *traffic_ops.TrafficMonitorConfigMap) (bool, string) { toServer := mc.TrafficServer[string(result.ID)] @@ -114,7 +119,7 @@ func EvalCache(result cache.Result, mc *traffic_ops.TrafficMonitorConfigMap) (bo return false, fmt.Sprintf("error: %v", result.Error) case result.Vitals.LoadAvg > params.HealthThresholdLoadAvg: return false, fmt.Sprintf("load average %f exceeds threshold %f", result.Vitals.LoadAvg, params.HealthThresholdLoadAvg) - case result.Vitals.KbpsOut >= getKbpsThreshold(params.HealthThresholdAvailableBandwidthInKbps): + case result.Vitals.KbpsOut > cacheCapacityKbps(result)-getKbpsThreshold(params.HealthThresholdAvailableBandwidthInKbps): return false, fmt.Sprintf("%dkbps exceeds max %dkbps", result.Vitals.KbpsOut, getKbpsThreshold(params.HealthThresholdAvailableBandwidthInKbps)) case result.RequestTime > getQueryThreshold(int64(params.HealthThresholdQueryTime)): return false, fmt.Sprintf("request time %v exceeds max %v", result.RequestTime, getQueryThreshold(int64(params.HealthThresholdQueryTime)))