calculate tps_total

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/2e325e6f
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/2e325e6f
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/2e325e6f

Branch: refs/heads/master
Commit: 2e325e6f45f573ec421399caf82af18520b5bf69
Parents: 7adadd5
Author: David Neuman <david.neuma...@gmail.com>
Authored: Thu Jan 19 16:04:53 2017 -0700
Committer: Jeff Elsloo <jeffrey_els...@cable.comcast.com>
Committed: Tue Jan 24 08:38:45 2017 -0700

----------------------------------------------------------------------
 .../traffic_monitor/deliveryservice/stat.go       | 18 +++++++++++-------
 .../traffic_monitor/deliveryservicedata/stat.go   | 14 +++++++-------
 2 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2e325e6f/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
----------------------------------------------------------------------
diff --git 
a/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go 
b/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
index 6000012..5b47ecf 100644
--- a/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
+++ b/traffic_monitor/experimental/traffic_monitor/deliveryservice/stat.go
@@ -277,6 +277,7 @@ func addLastStatsToStatCacheStats(s dsdata.StatCacheStats, 
l LastStatsData) dsda
        s.Tps3xx.Value = l.Status3xx.PerSec
        s.Tps4xx.Value = l.Status4xx.PerSec
        s.Tps5xx.Value = l.Status5xx.PerSec
+       s.TpsTotal.Value = s.Tps2xx.Value + s.Tps3xx.Value + s.Tps4xx.Value + 
s.Tps5xx.Value
        return s
 }
 
@@ -467,7 +468,7 @@ func addStatCacheStats(s *dsdata.StatsOld, c 
dsdata.StatCacheStats, deliveryServ
        add("tps_3xx", fmt.Sprintf("%f", c.Tps3xx.Value))
        add("tps_2xx", fmt.Sprintf("%f", c.Tps2xx.Value))
        add("error-string", c.ErrorString.Value)
-       add("tps_total", strconv.Itoa(int(c.TpsTotal.Value)))
+       add("tps_total", fmt.Sprintf("%f", c.TpsTotal.Value))
        return s
 }
 
@@ -513,15 +514,18 @@ func (s Stats) JSON(filter dsdata.Filter, params 
url.Values) dsdata.StatsOld {
        return *jsonObj
 }
 
-func getDsErrString(dsName enum.DeliveryServiceName, dsStats dsdata.Stat, 
monitorConfig to.TrafficMonitorConfigMap) string {
+func getDsErrString(dsName enum.DeliveryServiceName, dsStats 
dsdata.StatCacheStats, monitorConfig to.TrafficMonitorConfigMap) string {
        dsNameString := fmt.Sprintf("%s", dsName)
+       if dsName == "adcolony" {
+               fmt.Printf("Stats 2xx = %v, Tps 2xx = %v, TPS total = %v\n", 
dsStats.Status2xx.Value, dsStats.Tps2xx.Value, dsStats.TpsTotal.Value)
+       }
 
-       if dsStats.Total().TpsTotal.Value > 
monitorConfig.DeliveryService[dsNameString].TotalTPSThreshold {
-               return fmt.Sprintf("TPSTotal too high (%v > %v)", 
dsStats.Total().TpsTotal.Value, 
monitorConfig.DeliveryService[dsNameString].TotalTPSThreshold)
-
+       if dsStats.TpsTotal.Value > 
float64(monitorConfig.DeliveryService[dsNameString].TotalTPSThreshold) {
+               return fmt.Sprintf("TPSTotal too high (%v > %v)", 
dsStats.TpsTotal.Value, 
monitorConfig.DeliveryService[dsNameString].TotalTPSThreshold)
        }
-       if dsStats.Total().Kbps.Value > 
float64(monitorConfig.DeliveryService[dsNameString].TotalKbpsThreshold) {
-               return fmt.Sprintf("TotalKbps too high (%v > %v)", 
dsStats.Total().Kbps.Value, 
monitorConfig.DeliveryService[dsNameString].TotalTPSThreshold)
+
+       if dsStats.Kbps.Value > 
float64(monitorConfig.DeliveryService[dsNameString].TotalKbpsThreshold) {
+               return fmt.Sprintf("TotalKbps too high (%v > %v)", 
dsStats.Kbps.Value, 
monitorConfig.DeliveryService[dsNameString].TotalTPSThreshold)
        }
        return ""
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2e325e6f/traffic_monitor/experimental/traffic_monitor/deliveryservicedata/stat.go
----------------------------------------------------------------------
diff --git 
a/traffic_monitor/experimental/traffic_monitor/deliveryservicedata/stat.go 
b/traffic_monitor/experimental/traffic_monitor/deliveryservicedata/stat.go
index cce4a8e..ae79b08 100644
--- a/traffic_monitor/experimental/traffic_monitor/deliveryservicedata/stat.go
+++ b/traffic_monitor/experimental/traffic_monitor/deliveryservicedata/stat.go
@@ -8,9 +8,9 @@ package deliveryservicedata // TODO rename?
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,13 +19,13 @@ package deliveryservicedata // TODO rename?
  * under the License.
  */
 
-
 import (
        "errors"
-       
"github.com/apache/incubator-trafficcontrol/traffic_monitor/experimental/traffic_monitor/enum"
-       
"github.com/apache/incubator-trafficcontrol/traffic_monitor/experimental/traffic_monitor/srvhttp"
        "net/url"
        "time"
+
+       
"github.com/apache/incubator-trafficcontrol/traffic_monitor/experimental/traffic_monitor/enum"
+       
"github.com/apache/incubator-trafficcontrol/traffic_monitor/experimental/traffic_monitor/srvhttp"
 )
 
 // Filter encapsulates functions to filter a given set of Stats, e.g. from 
HTTP query parameters.
@@ -191,7 +191,7 @@ type StatCacheStats struct {
        Tps3xx      StatFloat  `json:"tps_3xx"`
        Tps2xx      StatFloat  `json:"tps_2xx"`
        ErrorString StatString `json:"error_string"`
-       TpsTotal    StatInt    `json:"tps_total"`
+       TpsTotal    StatFloat  `json:"tps_total"`
 }
 
 // Sum adds the given cache stats to this cache stats. Numeric values are 
summed; strings are appended.
@@ -210,7 +210,7 @@ func (a StatCacheStats) Sum(b StatCacheStats) 
StatCacheStats {
                Tps3xx:      StatFloat{Value: a.Tps3xx.Value + b.Tps3xx.Value},
                Tps2xx:      StatFloat{Value: a.Tps2xx.Value + b.Tps2xx.Value},
                ErrorString: StatString{Value: a.ErrorString.Value + 
b.ErrorString.Value},
-               TpsTotal:    StatInt{Value: a.TpsTotal.Value + 
b.TpsTotal.Value},
+               TpsTotal:    StatFloat{Value: a.TpsTotal.Value + 
b.TpsTotal.Value},
        }
 }
 

Reply via email to