Exemplo n.º 1
0
func addCommonData(s *dsdata.StatsOld, c *dsdata.StatCommon, deliveryService enum.DeliveryServiceName, t int64, filter dsdata.Filter) *dsdata.StatsOld {
	add := func(name, val string) {
		if filter.UseStat(name) {
			s.DeliveryService[deliveryService][dsdata.StatName(name)] = []dsdata.StatOld{dsdata.StatOld{Time: t, Value: val}}
		}
	}
	add("caches-configured", strconv.Itoa(int(c.CachesConfiguredNum.Value)))
	add("caches-reporting", strconv.Itoa(len(c.CachesReporting)))
	add("error-string", strconv.Itoa(len(c.CachesReporting)))
	add("status", c.StatusStr.Value)
	add("isHealthy", fmt.Sprintf("%t", c.IsHealthy.Value))
	add("isAvailable", fmt.Sprintf("%t", c.IsAvailable.Value))
	add("caches-available", strconv.Itoa(int(c.CachesAvailableNum.Value)))
	return s
}
Exemplo n.º 2
0
func addStatCacheStats(s *dsdata.StatsOld, c dsdata.StatCacheStats, deliveryService enum.DeliveryServiceName, prefix string, t int64, filter dsdata.Filter) *dsdata.StatsOld {
	add := func(name, val string) {
		if filter.UseStat(name) {
			s.DeliveryService[deliveryService][dsdata.StatName(prefix+name)] = []dsdata.StatOld{dsdata.StatOld{Time: t, Value: val}}
		}
	}
	add("out_bytes", strconv.Itoa(int(c.OutBytes.Value)))
	add("isAvailable", fmt.Sprintf("%t", c.IsAvailable.Value))
	add("status_5xx", strconv.Itoa(int(c.Status5xx.Value)))
	add("status_4xx", strconv.Itoa(int(c.Status4xx.Value)))
	add("status_3xx", strconv.Itoa(int(c.Status3xx.Value)))
	add("status_2xx", strconv.Itoa(int(c.Status2xx.Value)))
	add("in_bytes", strconv.Itoa(int(c.InBytes.Value)))
	add("kbps", strconv.Itoa(int(c.Kbps.Value)))
	add("tps_5xx", fmt.Sprintf("%f", c.Tps5xx.Value))
	add("tps_4xx", fmt.Sprintf("%f", c.Tps4xx.Value))
	add("tps_3xx", fmt.Sprintf("%f", c.Tps3xx.Value))
	add("tps_2xx", fmt.Sprintf("%f", c.Tps2xx.Value))
	add("error", c.ErrorString.Value)
	add("tps_total", strconv.Itoa(int(c.TpsTotal.Value)))
	return s
}