mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-23 15:00:25 +08:00
优化看板
This commit is contained in:
@@ -72,14 +72,18 @@ func (this *ServerDailyStatDAO) SaveStats(tx *dbs.Tx, stats []*pb.ServerDailySta
|
|||||||
Param("cachedBytes", stat.CachedBytes).
|
Param("cachedBytes", stat.CachedBytes).
|
||||||
Param("countRequests", stat.CountRequests).
|
Param("countRequests", stat.CountRequests).
|
||||||
Param("countCachedRequests", stat.CountCachedRequests).
|
Param("countCachedRequests", stat.CountCachedRequests).
|
||||||
|
Param("countAttackRequests", stat.CountAttackRequests).
|
||||||
|
Param("attackBytes", stat.AttackBytes).
|
||||||
InsertOrUpdate(maps.Map{
|
InsertOrUpdate(maps.Map{
|
||||||
"userId": serverUserId,
|
"userId": serverUserId,
|
||||||
"serverId": stat.ServerId,
|
"serverId": stat.ServerId,
|
||||||
"regionId": stat.RegionId,
|
"regionId": stat.RegionId,
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": stat.Bytes,
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": stat.CachedBytes,
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": stat.CountRequests,
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": stat.CountCachedRequests,
|
||||||
|
"countAttackRequests": stat.CountAttackRequests,
|
||||||
|
"attackBytes": stat.AttackBytes,
|
||||||
"day": day,
|
"day": day,
|
||||||
"hour": hour,
|
"hour": hour,
|
||||||
"timeFrom": timeFrom,
|
"timeFrom": timeFrom,
|
||||||
@@ -89,6 +93,8 @@ func (this *ServerDailyStatDAO) SaveStats(tx *dbs.Tx, stats []*pb.ServerDailySta
|
|||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -165,7 +171,7 @@ func (this *ServerDailyStatDAO) SumMinutelyStat(tx *dbs.Tx, serverId int64, minu
|
|||||||
}
|
}
|
||||||
|
|
||||||
one, _, err := this.Query(tx).
|
one, _, err := this.Query(tx).
|
||||||
Result("SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Attr("serverId", serverId).
|
Attr("serverId", serverId).
|
||||||
Attr("day", minute[:8]).
|
Attr("day", minute[:8]).
|
||||||
Attr("timeFrom", minute[8:]+"00").
|
Attr("timeFrom", minute[8:]+"00").
|
||||||
@@ -182,6 +188,8 @@ func (this *ServerDailyStatDAO) SumMinutelyStat(tx *dbs.Tx, serverId int64, minu
|
|||||||
stat.CachedBytes = one.GetInt64("cachedBytes")
|
stat.CachedBytes = one.GetInt64("cachedBytes")
|
||||||
stat.CountRequests = one.GetInt64("countRequests")
|
stat.CountRequests = one.GetInt64("countRequests")
|
||||||
stat.CountCachedRequests = one.GetInt64("countCachedRequests")
|
stat.CountCachedRequests = one.GetInt64("countCachedRequests")
|
||||||
|
stat.CountAttackRequests = one.GetInt64("countAttackRequests")
|
||||||
|
stat.AttackBytes = one.GetInt64("attackBytes")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +203,7 @@ func (this *ServerDailyStatDAO) SumHourlyStat(tx *dbs.Tx, serverId int64, hour s
|
|||||||
}
|
}
|
||||||
|
|
||||||
one, _, err := this.Query(tx).
|
one, _, err := this.Query(tx).
|
||||||
Result("SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Attr("serverId", serverId).
|
Attr("serverId", serverId).
|
||||||
Attr("day", hour[:8]).
|
Attr("day", hour[:8]).
|
||||||
Gte("timeFrom", hour[8:]+"0000").
|
Gte("timeFrom", hour[8:]+"0000").
|
||||||
@@ -213,6 +221,8 @@ func (this *ServerDailyStatDAO) SumHourlyStat(tx *dbs.Tx, serverId int64, hour s
|
|||||||
stat.CachedBytes = one.GetInt64("cachedBytes")
|
stat.CachedBytes = one.GetInt64("cachedBytes")
|
||||||
stat.CountRequests = one.GetInt64("countRequests")
|
stat.CountRequests = one.GetInt64("countRequests")
|
||||||
stat.CountCachedRequests = one.GetInt64("countCachedRequests")
|
stat.CountCachedRequests = one.GetInt64("countCachedRequests")
|
||||||
|
stat.CountAttackRequests = one.GetInt64("countAttackRequests")
|
||||||
|
stat.AttackBytes = one.GetInt64("attackBytes")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +236,7 @@ func (this *ServerDailyStatDAO) SumDailyStat(tx *dbs.Tx, serverId int64, day str
|
|||||||
}
|
}
|
||||||
|
|
||||||
one, _, err := this.Query(tx).
|
one, _, err := this.Query(tx).
|
||||||
Result("SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Attr("serverId", serverId).
|
Attr("serverId", serverId).
|
||||||
Attr("day", day).
|
Attr("day", day).
|
||||||
FindOne()
|
FindOne()
|
||||||
@@ -242,13 +252,15 @@ func (this *ServerDailyStatDAO) SumDailyStat(tx *dbs.Tx, serverId int64, day str
|
|||||||
stat.CachedBytes = one.GetInt64("cachedBytes")
|
stat.CachedBytes = one.GetInt64("cachedBytes")
|
||||||
stat.CountRequests = one.GetInt64("countRequests")
|
stat.CountRequests = one.GetInt64("countRequests")
|
||||||
stat.CountCachedRequests = one.GetInt64("countCachedRequests")
|
stat.CountCachedRequests = one.GetInt64("countCachedRequests")
|
||||||
|
stat.CountAttackRequests = one.GetInt64("countAttackRequests")
|
||||||
|
stat.AttackBytes = one.GetInt64("attackBytes")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindDailyStats 按天统计
|
// FindDailyStats 按天统计
|
||||||
func (this *ServerDailyStatDAO) FindDailyStats(tx *dbs.Tx, serverId int64, dayFrom string, dayTo string) (result []*ServerDailyStat, err error) {
|
func (this *ServerDailyStatDAO) FindDailyStats(tx *dbs.Tx, serverId int64, dayFrom string, dayTo string) (result []*ServerDailyStat, err error) {
|
||||||
ones, err := this.Query(tx).
|
ones, err := this.Query(tx).
|
||||||
Result("SUM(bytes) AS bytes", "SUM(cachedBytes) AS cachedBytes", "SUM(countRequests) AS countRequests", "SUM(countCachedRequests) AS countCachedRequests", "day").
|
Result("SUM(bytes) AS bytes", "SUM(cachedBytes) AS cachedBytes", "SUM(countRequests) AS countRequests", "SUM(countCachedRequests) AS countCachedRequests", "SUM(countAttackRequests) AS countAttackRequests", "SUM(attackBytes) AS attackBytes", "day").
|
||||||
Attr("serverId", serverId).
|
Attr("serverId", serverId).
|
||||||
Between("day", dayFrom, dayTo).
|
Between("day", dayFrom, dayTo).
|
||||||
Group("day").
|
Group("day").
|
||||||
@@ -281,7 +293,7 @@ func (this *ServerDailyStatDAO) FindDailyStats(tx *dbs.Tx, serverId int64, dayFr
|
|||||||
// FindHourlyStats 按小时统计
|
// FindHourlyStats 按小时统计
|
||||||
func (this *ServerDailyStatDAO) FindHourlyStats(tx *dbs.Tx, serverId int64, hourFrom string, hourTo string) (result []*ServerDailyStat, err error) {
|
func (this *ServerDailyStatDAO) FindHourlyStats(tx *dbs.Tx, serverId int64, hourFrom string, hourTo string) (result []*ServerDailyStat, err error) {
|
||||||
ones, err := this.Query(tx).
|
ones, err := this.Query(tx).
|
||||||
Result("SUM(bytes) AS bytes", "SUM(cachedBytes) AS cachedBytes", "SUM(countRequests) AS countRequests", "SUM(countCachedRequests) AS countCachedRequests", "hour").
|
Result("SUM(bytes) AS bytes", "SUM(cachedBytes) AS cachedBytes", "SUM(countRequests) AS countRequests", "SUM(countCachedRequests) AS countCachedRequests", "SUM(countAttackRequests) AS countAttackRequests", "SUM(attackBytes) AS attackBytes", "hour").
|
||||||
Attr("serverId", serverId).
|
Attr("serverId", serverId).
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Group("hour").
|
Group("hour").
|
||||||
@@ -314,7 +326,7 @@ func (this *ServerDailyStatDAO) FindHourlyStats(tx *dbs.Tx, serverId int64, hour
|
|||||||
// FindTopUserStats 流量排行
|
// FindTopUserStats 流量排行
|
||||||
func (this *ServerDailyStatDAO) FindTopUserStats(tx *dbs.Tx, hourFrom string, hourTo string) (result []*ServerDailyStat, err error) {
|
func (this *ServerDailyStatDAO) FindTopUserStats(tx *dbs.Tx, hourFrom string, hourTo string) (result []*ServerDailyStat, err error) {
|
||||||
_, err = this.Query(tx).
|
_, err = this.Query(tx).
|
||||||
Result("userId", "SUM(bytes) AS bytes", "SUM(countRequests) AS countRequests").
|
Result("userId", "SUM(bytes) AS bytes", "SUM(countRequests) AS countRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Where("userId>0").
|
Where("userId>0").
|
||||||
Group("userId").
|
Group("userId").
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ type ServerDailyStat struct {
|
|||||||
CachedBytes uint64 `field:"cachedBytes"` // 缓存的流量
|
CachedBytes uint64 `field:"cachedBytes"` // 缓存的流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
||||||
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击请求数
|
||||||
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
Day string `field:"day"` // 日期YYYYMMDD
|
Day string `field:"day"` // 日期YYYYMMDD
|
||||||
Hour string `field:"hour"` // YYYYMMDDHH
|
Hour string `field:"hour"` // YYYYMMDDHH
|
||||||
TimeFrom string `field:"timeFrom"` // 开始时间HHMMSS
|
TimeFrom string `field:"timeFrom"` // 开始时间HHMMSS
|
||||||
@@ -26,6 +28,8 @@ type ServerDailyStatOperator struct {
|
|||||||
CachedBytes interface{} // 缓存的流量
|
CachedBytes interface{} // 缓存的流量
|
||||||
CountRequests interface{} // 请求数
|
CountRequests interface{} // 请求数
|
||||||
CountCachedRequests interface{} // 缓存的请求数
|
CountCachedRequests interface{} // 缓存的请求数
|
||||||
|
CountAttackRequests interface{} // 攻击请求数
|
||||||
|
AttackBytes interface{} // 攻击流量
|
||||||
Day interface{} // 日期YYYYMMDD
|
Day interface{} // 日期YYYYMMDD
|
||||||
Hour interface{} // YYYYMMDDHH
|
Hour interface{} // YYYYMMDDHH
|
||||||
TimeFrom interface{} // 开始时间HHMMSS
|
TimeFrom interface{} // 开始时间HHMMSS
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseDailyStat 增加统计数据
|
// IncreaseDailyStat 增加统计数据
|
||||||
func (this *NodeClusterTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, clusterId int64, day string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64) error {
|
func (this *NodeClusterTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, clusterId int64, day string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64, attackBytes int64) error {
|
||||||
if len(day) != 8 {
|
if len(day) != 8 {
|
||||||
return errors.New("invalid day '" + day + "'")
|
return errors.New("invalid day '" + day + "'")
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,8 @@ func (this *NodeClusterTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, cluste
|
|||||||
Param("cachedBytes", cachedBytes).
|
Param("cachedBytes", cachedBytes).
|
||||||
Param("countRequests", countRequests).
|
Param("countRequests", countRequests).
|
||||||
Param("countCachedRequests", countCachedRequests).
|
Param("countCachedRequests", countCachedRequests).
|
||||||
|
Param("countAttackRequests", countAttackRequests).
|
||||||
|
Param("attackBytes", attackBytes).
|
||||||
InsertOrUpdateQuickly(maps.Map{
|
InsertOrUpdateQuickly(maps.Map{
|
||||||
"clusterId": clusterId,
|
"clusterId": clusterId,
|
||||||
"day": day,
|
"day": day,
|
||||||
@@ -65,11 +67,15 @@ func (this *NodeClusterTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, cluste
|
|||||||
"cachedBytes": cachedBytes,
|
"cachedBytes": cachedBytes,
|
||||||
"countRequests": countRequests,
|
"countRequests": countRequests,
|
||||||
"countCachedRequests": countCachedRequests,
|
"countCachedRequests": countCachedRequests,
|
||||||
|
"countAttackRequests": countAttackRequests,
|
||||||
|
"attackBytes": attackBytes,
|
||||||
}, maps.Map{
|
}, maps.Map{
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": dbs.SQL("bytes+:bytes"),
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ type NodeClusterTrafficDailyStat struct {
|
|||||||
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
||||||
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击请求数
|
||||||
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeClusterTrafficDailyStatOperator struct {
|
type NodeClusterTrafficDailyStatOperator struct {
|
||||||
@@ -19,6 +21,8 @@ type NodeClusterTrafficDailyStatOperator struct {
|
|||||||
CachedBytes interface{} // 缓存流量
|
CachedBytes interface{} // 缓存流量
|
||||||
CountRequests interface{} // 请求数
|
CountRequests interface{} // 请求数
|
||||||
CountCachedRequests interface{} // 缓存的请求数
|
CountCachedRequests interface{} // 缓存的请求数
|
||||||
|
CountAttackRequests interface{} // 攻击请求数
|
||||||
|
AttackBytes interface{} // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeClusterTrafficDailyStatOperator() *NodeClusterTrafficDailyStatOperator {
|
func NewNodeClusterTrafficDailyStatOperator() *NodeClusterTrafficDailyStatOperator {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseDailyStat 增加统计数据
|
// IncreaseDailyStat 增加统计数据
|
||||||
func (this *NodeTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, clusterId int64, role string, nodeId int64, day string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64) error {
|
func (this *NodeTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, clusterId int64, role string, nodeId int64, day string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64, attackBytes int64) error {
|
||||||
if len(day) != 8 {
|
if len(day) != 8 {
|
||||||
return errors.New("invalid day '" + day + "'")
|
return errors.New("invalid day '" + day + "'")
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,8 @@ func (this *NodeTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, clusterId int
|
|||||||
Param("cachedBytes", cachedBytes).
|
Param("cachedBytes", cachedBytes).
|
||||||
Param("countRequests", countRequests).
|
Param("countRequests", countRequests).
|
||||||
Param("countCachedRequests", countCachedRequests).
|
Param("countCachedRequests", countCachedRequests).
|
||||||
|
Param("countAttackRequests", countAttackRequests).
|
||||||
|
Param("attackBytes", attackBytes).
|
||||||
InsertOrUpdateQuickly(maps.Map{
|
InsertOrUpdateQuickly(maps.Map{
|
||||||
"clusterId": clusterId,
|
"clusterId": clusterId,
|
||||||
"role": role,
|
"role": role,
|
||||||
@@ -67,11 +69,15 @@ func (this *NodeTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, clusterId int
|
|||||||
"cachedBytes": cachedBytes,
|
"cachedBytes": cachedBytes,
|
||||||
"countRequests": countRequests,
|
"countRequests": countRequests,
|
||||||
"countCachedRequests": countCachedRequests,
|
"countCachedRequests": countCachedRequests,
|
||||||
|
"countAttackRequests": countAttackRequests,
|
||||||
|
"attackBytes": attackBytes,
|
||||||
}, maps.Map{
|
}, maps.Map{
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": dbs.SQL("bytes+:bytes"),
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -79,7 +85,6 @@ func (this *NodeTrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, clusterId int
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FindDailyStats 获取日期之间统计
|
// FindDailyStats 获取日期之间统计
|
||||||
func (this *NodeTrafficDailyStatDAO) FindDailyStats(tx *dbs.Tx, role string, nodeId int64, dayFrom string, dayTo string) (result []*NodeTrafficDailyStat, err error) {
|
func (this *NodeTrafficDailyStatDAO) FindDailyStats(tx *dbs.Tx, role string, nodeId int64, dayFrom string, dayTo string) (result []*NodeTrafficDailyStat, err error) {
|
||||||
ones, err := this.Query(tx).
|
ones, err := this.Query(tx).
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ type NodeTrafficDailyStat struct {
|
|||||||
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
||||||
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击数
|
||||||
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeTrafficDailyStatOperator struct {
|
type NodeTrafficDailyStatOperator struct {
|
||||||
@@ -23,6 +25,8 @@ type NodeTrafficDailyStatOperator struct {
|
|||||||
CachedBytes interface{} // 缓存流量
|
CachedBytes interface{} // 缓存流量
|
||||||
CountRequests interface{} // 请求数
|
CountRequests interface{} // 请求数
|
||||||
CountCachedRequests interface{} // 缓存的请求数
|
CountCachedRequests interface{} // 缓存的请求数
|
||||||
|
CountAttackRequests interface{} // 攻击数
|
||||||
|
AttackBytes interface{} // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeTrafficDailyStatOperator() *NodeTrafficDailyStatOperator {
|
func NewNodeTrafficDailyStatOperator() *NodeTrafficDailyStatOperator {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseHourlyStat 增加统计数据
|
// IncreaseHourlyStat 增加统计数据
|
||||||
func (this *NodeTrafficHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId int64, role string, nodeId int64, hour string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64) error {
|
func (this *NodeTrafficHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId int64, role string, nodeId int64, hour string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64, attackBytes int64) error {
|
||||||
if len(hour) != 10 {
|
if len(hour) != 10 {
|
||||||
return errors.New("invalid hour '" + hour + "'")
|
return errors.New("invalid hour '" + hour + "'")
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,8 @@ func (this *NodeTrafficHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId i
|
|||||||
Param("cachedBytes", cachedBytes).
|
Param("cachedBytes", cachedBytes).
|
||||||
Param("countRequests", countRequests).
|
Param("countRequests", countRequests).
|
||||||
Param("countCachedRequests", countCachedRequests).
|
Param("countCachedRequests", countCachedRequests).
|
||||||
|
Param("countAttackRequests", countAttackRequests).
|
||||||
|
Param("attackBytes", attackBytes).
|
||||||
InsertOrUpdateQuickly(maps.Map{
|
InsertOrUpdateQuickly(maps.Map{
|
||||||
"clusterId": clusterId,
|
"clusterId": clusterId,
|
||||||
"role": role,
|
"role": role,
|
||||||
@@ -67,11 +69,15 @@ func (this *NodeTrafficHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId i
|
|||||||
"cachedBytes": cachedBytes,
|
"cachedBytes": cachedBytes,
|
||||||
"countRequests": countRequests,
|
"countRequests": countRequests,
|
||||||
"countCachedRequests": countCachedRequests,
|
"countCachedRequests": countCachedRequests,
|
||||||
|
"countAttackRequests": countAttackRequests,
|
||||||
|
"attackBytes": attackBytes,
|
||||||
}, maps.Map{
|
}, maps.Map{
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": dbs.SQL("bytes+:bytes"),
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -84,7 +90,7 @@ func (this *NodeTrafficHourlyStatDAO) FindHourlyStatsWithClusterId(tx *dbs.Tx, c
|
|||||||
ones, err := this.Query(tx).
|
ones, err := this.Query(tx).
|
||||||
Attr("clusterId", clusterId).
|
Attr("clusterId", clusterId).
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Result("hour, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("hour, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Group("hour").
|
Group("hour").
|
||||||
FindAll()
|
FindAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -110,6 +116,20 @@ func (this *NodeTrafficHourlyStatDAO) FindHourlyStatsWithClusterId(tx *dbs.Tx, c
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindTopNodeStats 取得一定时间内的节点排行数据
|
||||||
|
func (this *NodeTrafficHourlyStatDAO) FindTopNodeStats(tx *dbs.Tx, role string, hourFrom string, hourTo string) (result []*NodeTrafficHourlyStat, err error) {
|
||||||
|
// TODO 节点如果已经被删除,则忽略
|
||||||
|
_, err = this.Query(tx).
|
||||||
|
Attr("role", role).
|
||||||
|
Between("hour", hourFrom, hourTo).
|
||||||
|
Result("nodeId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
|
Group("nodeId").
|
||||||
|
Desc("countRequests").
|
||||||
|
Slice(&result).
|
||||||
|
FindAll()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// FindTopNodeStatsWithClusterId 取得集群一定时间内的节点排行数据
|
// FindTopNodeStatsWithClusterId 取得集群一定时间内的节点排行数据
|
||||||
func (this *NodeTrafficHourlyStatDAO) FindTopNodeStatsWithClusterId(tx *dbs.Tx, role string, clusterId int64, hourFrom string, hourTo string) (result []*NodeTrafficHourlyStat, err error) {
|
func (this *NodeTrafficHourlyStatDAO) FindTopNodeStatsWithClusterId(tx *dbs.Tx, role string, clusterId int64, hourFrom string, hourTo string) (result []*NodeTrafficHourlyStat, err error) {
|
||||||
// TODO 节点如果已经被删除,则忽略
|
// TODO 节点如果已经被删除,则忽略
|
||||||
@@ -117,7 +137,7 @@ func (this *NodeTrafficHourlyStatDAO) FindTopNodeStatsWithClusterId(tx *dbs.Tx,
|
|||||||
Attr("role", role).
|
Attr("role", role).
|
||||||
Attr("clusterId", clusterId).
|
Attr("clusterId", clusterId).
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Result("nodeId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("nodeId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Group("nodeId").
|
Group("nodeId").
|
||||||
Desc("countRequests").
|
Desc("countRequests").
|
||||||
Slice(&result).
|
Slice(&result).
|
||||||
@@ -131,7 +151,7 @@ func (this *NodeTrafficHourlyStatDAO) FindHourlyStatsWithNodeId(tx *dbs.Tx, role
|
|||||||
Attr("role", role).
|
Attr("role", role).
|
||||||
Attr("nodeId", nodeId).
|
Attr("nodeId", nodeId).
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Result("hour, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("hour, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Group("hour").
|
Group("hour").
|
||||||
FindAll()
|
FindAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ type NodeTrafficHourlyStat struct {
|
|||||||
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
||||||
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击请求数
|
||||||
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeTrafficHourlyStatOperator struct {
|
type NodeTrafficHourlyStatOperator struct {
|
||||||
@@ -23,6 +25,8 @@ type NodeTrafficHourlyStatOperator struct {
|
|||||||
CachedBytes interface{} // 缓存流量
|
CachedBytes interface{} // 缓存流量
|
||||||
CountRequests interface{} // 请求数
|
CountRequests interface{} // 请求数
|
||||||
CountCachedRequests interface{} // 缓存的请求数
|
CountCachedRequests interface{} // 缓存的请求数
|
||||||
|
CountAttackRequests interface{} // 攻击请求数
|
||||||
|
AttackBytes interface{} // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeTrafficHourlyStatOperator() *NodeTrafficHourlyStatOperator {
|
func NewNodeTrafficHourlyStatOperator() *NodeTrafficHourlyStatOperator {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseHourlyStat 增加统计数据
|
// IncreaseHourlyStat 增加统计数据
|
||||||
func (this *ServerDomainHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId int64, nodeId int64, serverId int64, domain string, hour string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64) error {
|
func (this *ServerDomainHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId int64, nodeId int64, serverId int64, domain string, hour string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64, attackBytes int64) error {
|
||||||
if len(hour) != 10 {
|
if len(hour) != 10 {
|
||||||
return errors.New("invalid hour '" + hour + "'")
|
return errors.New("invalid hour '" + hour + "'")
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,8 @@ func (this *ServerDomainHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId
|
|||||||
Param("cachedBytes", cachedBytes).
|
Param("cachedBytes", cachedBytes).
|
||||||
Param("countRequests", countRequests).
|
Param("countRequests", countRequests).
|
||||||
Param("countCachedRequests", countCachedRequests).
|
Param("countCachedRequests", countCachedRequests).
|
||||||
|
Param("countAttackRequests", countAttackRequests).
|
||||||
|
Param("attackBytes", attackBytes).
|
||||||
InsertOrUpdateQuickly(maps.Map{
|
InsertOrUpdateQuickly(maps.Map{
|
||||||
"clusterId": clusterId,
|
"clusterId": clusterId,
|
||||||
"nodeId": nodeId,
|
"nodeId": nodeId,
|
||||||
@@ -67,11 +69,15 @@ func (this *ServerDomainHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId
|
|||||||
"cachedBytes": cachedBytes,
|
"cachedBytes": cachedBytes,
|
||||||
"countRequests": countRequests,
|
"countRequests": countRequests,
|
||||||
"countCachedRequests": countCachedRequests,
|
"countCachedRequests": countCachedRequests,
|
||||||
|
"countAttackRequests": countAttackRequests,
|
||||||
|
"attackBytes": attackBytes,
|
||||||
}, maps.Map{
|
}, maps.Map{
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": dbs.SQL("bytes+:bytes"),
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -79,13 +85,26 @@ func (this *ServerDomainHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, clusterId
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindTopDomainStats 取得一定时间内的域名排行数据
|
||||||
|
func (this *ServerDomainHourlyStatDAO) FindTopDomainStats(tx *dbs.Tx, hourFrom string, hourTo string) (result []*ServerDomainHourlyStat, err error) {
|
||||||
|
// TODO 节点如果已经被删除,则忽略
|
||||||
|
_, err = this.Query(tx).
|
||||||
|
Between("hour", hourFrom, hourTo).
|
||||||
|
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
|
Group("domain").
|
||||||
|
Desc("countRequests").
|
||||||
|
Slice(&result).
|
||||||
|
FindAll()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// FindTopDomainStatsWithClusterId 取得集群上的一定时间内的域名排行数据
|
// FindTopDomainStatsWithClusterId 取得集群上的一定时间内的域名排行数据
|
||||||
func (this *ServerDomainHourlyStatDAO) FindTopDomainStatsWithClusterId(tx *dbs.Tx, clusterId int64, hourFrom string, hourTo string) (result []*ServerDomainHourlyStat, err error) {
|
func (this *ServerDomainHourlyStatDAO) FindTopDomainStatsWithClusterId(tx *dbs.Tx, clusterId int64, hourFrom string, hourTo string) (result []*ServerDomainHourlyStat, err error) {
|
||||||
// TODO 节点如果已经被删除,则忽略
|
// TODO 节点如果已经被删除,则忽略
|
||||||
_, err = this.Query(tx).
|
_, err = this.Query(tx).
|
||||||
Attr("clusterId", clusterId).
|
Attr("clusterId", clusterId).
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Group("domain").
|
Group("domain").
|
||||||
Desc("countRequests").
|
Desc("countRequests").
|
||||||
Slice(&result).
|
Slice(&result).
|
||||||
@@ -99,7 +118,7 @@ func (this *ServerDomainHourlyStatDAO) FindTopDomainStatsWithNodeId(tx *dbs.Tx,
|
|||||||
_, err = this.Query(tx).
|
_, err = this.Query(tx).
|
||||||
Attr("nodeId", nodeId).
|
Attr("nodeId", nodeId).
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Group("domain").
|
Group("domain").
|
||||||
Desc("countRequests").
|
Desc("countRequests").
|
||||||
Slice(&result).
|
Slice(&result).
|
||||||
@@ -113,7 +132,7 @@ func (this *ServerDomainHourlyStatDAO) FindTopDomainStatsWithServerId(tx *dbs.Tx
|
|||||||
_, err = this.Query(tx).
|
_, err = this.Query(tx).
|
||||||
Attr("serverId", serverId).
|
Attr("serverId", serverId).
|
||||||
Between("hour", hourFrom, hourTo).
|
Between("hour", hourFrom, hourTo).
|
||||||
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests").
|
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||||
Group("domain").
|
Group("domain").
|
||||||
Desc("countRequests").
|
Desc("countRequests").
|
||||||
Slice(&result).
|
Slice(&result).
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ type ServerDomainHourlyStat struct {
|
|||||||
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存请求
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存请求
|
||||||
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击请求数
|
||||||
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerDomainHourlyStatOperator struct {
|
type ServerDomainHourlyStatOperator struct {
|
||||||
@@ -25,6 +27,8 @@ type ServerDomainHourlyStatOperator struct {
|
|||||||
CachedBytes interface{} // 缓存流量
|
CachedBytes interface{} // 缓存流量
|
||||||
CountRequests interface{} // 请求数
|
CountRequests interface{} // 请求数
|
||||||
CountCachedRequests interface{} // 缓存请求
|
CountCachedRequests interface{} // 缓存请求
|
||||||
|
CountAttackRequests interface{} // 攻击请求数
|
||||||
|
AttackBytes interface{} // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServerDomainHourlyStatOperator() *ServerDomainHourlyStatOperator {
|
func NewServerDomainHourlyStatOperator() *ServerDomainHourlyStatOperator {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseDailyStat 增加统计数据
|
// IncreaseDailyStat 增加统计数据
|
||||||
func (this *TrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, day string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64) error {
|
func (this *TrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, day string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64, attackBytes int64) error {
|
||||||
if len(day) != 8 {
|
if len(day) != 8 {
|
||||||
return errors.New("invalid day '" + day + "'")
|
return errors.New("invalid day '" + day + "'")
|
||||||
}
|
}
|
||||||
@@ -58,17 +58,23 @@ func (this *TrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, day string, bytes
|
|||||||
Param("cachedBytes", cachedBytes).
|
Param("cachedBytes", cachedBytes).
|
||||||
Param("countRequests", countRequests).
|
Param("countRequests", countRequests).
|
||||||
Param("countCachedRequests", countCachedRequests).
|
Param("countCachedRequests", countCachedRequests).
|
||||||
|
Param("countAttackRequests", countAttackRequests).
|
||||||
|
Param("attackBytes", attackBytes).
|
||||||
InsertOrUpdateQuickly(maps.Map{
|
InsertOrUpdateQuickly(maps.Map{
|
||||||
"day": day,
|
"day": day,
|
||||||
"bytes": bytes,
|
"bytes": bytes,
|
||||||
"cachedBytes": cachedBytes,
|
"cachedBytes": cachedBytes,
|
||||||
"countRequests": countRequests,
|
"countRequests": countRequests,
|
||||||
"countCachedRequests": countCachedRequests,
|
"countCachedRequests": countCachedRequests,
|
||||||
|
"countAttackRequests": countAttackRequests,
|
||||||
|
"attackBytes": attackBytes,
|
||||||
}, maps.Map{
|
}, maps.Map{
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": dbs.SQL("bytes+:bytes"),
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ type TrafficDailyStat struct {
|
|||||||
Bytes uint64 `field:"bytes"` // 流量字节
|
Bytes uint64 `field:"bytes"` // 流量字节
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存请求数
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存请求数
|
||||||
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击量
|
||||||
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrafficDailyStatOperator struct {
|
type TrafficDailyStatOperator struct {
|
||||||
@@ -17,6 +19,8 @@ type TrafficDailyStatOperator struct {
|
|||||||
Bytes interface{} // 流量字节
|
Bytes interface{} // 流量字节
|
||||||
CountRequests interface{} // 请求数
|
CountRequests interface{} // 请求数
|
||||||
CountCachedRequests interface{} // 缓存请求数
|
CountCachedRequests interface{} // 缓存请求数
|
||||||
|
CountAttackRequests interface{} // 攻击量
|
||||||
|
AttackBytes interface{} // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTrafficDailyStatOperator() *TrafficDailyStatOperator {
|
func NewTrafficDailyStatOperator() *TrafficDailyStatOperator {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseHourlyStat 增加流量
|
// IncreaseHourlyStat 增加流量
|
||||||
func (this *TrafficHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, hour string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64) error {
|
func (this *TrafficHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, hour string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64, attackBytes int64) error {
|
||||||
if len(hour) != 10 {
|
if len(hour) != 10 {
|
||||||
return errors.New("invalid hour '" + hour + "'")
|
return errors.New("invalid hour '" + hour + "'")
|
||||||
}
|
}
|
||||||
@@ -58,17 +58,23 @@ func (this *TrafficHourlyStatDAO) IncreaseHourlyStat(tx *dbs.Tx, hour string, by
|
|||||||
Param("cachedBytes", cachedBytes).
|
Param("cachedBytes", cachedBytes).
|
||||||
Param("countRequests", countRequests).
|
Param("countRequests", countRequests).
|
||||||
Param("countCachedRequests", countCachedRequests).
|
Param("countCachedRequests", countCachedRequests).
|
||||||
|
Param("countAttackRequests", countAttackRequests).
|
||||||
|
Param("attackBytes", attackBytes).
|
||||||
InsertOrUpdateQuickly(maps.Map{
|
InsertOrUpdateQuickly(maps.Map{
|
||||||
"hour": hour,
|
"hour": hour,
|
||||||
"bytes": bytes,
|
"bytes": bytes,
|
||||||
"cachedBytes": cachedBytes,
|
"cachedBytes": cachedBytes,
|
||||||
"countRequests": countRequests,
|
"countRequests": countRequests,
|
||||||
"countCachedRequests": countCachedRequests,
|
"countCachedRequests": countCachedRequests,
|
||||||
|
"countAttackRequests": countAttackRequests,
|
||||||
|
"attackBytes": attackBytes,
|
||||||
}, maps.Map{
|
}, maps.Map{
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": dbs.SQL("bytes+:bytes"),
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ type TrafficHourlyStat struct {
|
|||||||
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
CachedBytes uint64 `field:"cachedBytes"` // 缓存流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存请求数
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存请求数
|
||||||
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击数
|
||||||
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrafficHourlyStatOperator struct {
|
type TrafficHourlyStatOperator struct {
|
||||||
@@ -17,6 +19,8 @@ type TrafficHourlyStatOperator struct {
|
|||||||
CachedBytes interface{} // 缓存流量
|
CachedBytes interface{} // 缓存流量
|
||||||
CountRequests interface{} // 请求数
|
CountRequests interface{} // 请求数
|
||||||
CountCachedRequests interface{} // 缓存请求数
|
CountCachedRequests interface{} // 缓存请求数
|
||||||
|
CountAttackRequests interface{} // 攻击数
|
||||||
|
AttackBytes interface{} // 攻击流量
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTrafficHourlyStatOperator() *TrafficHourlyStatOperator {
|
func NewTrafficHourlyStatOperator() *TrafficHourlyStatOperator {
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &pb.ComposeAdminDashboardResponse{}
|
result := &pb.ComposeAdminDashboardResponse{}
|
||||||
|
|
||||||
var tx = this.NullTx()
|
var tx = this.NullTx()
|
||||||
|
|
||||||
@@ -477,49 +477,49 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.CountNodeClusters = countClusters
|
result.CountNodeClusters = countClusters
|
||||||
|
|
||||||
// 节点数
|
// 节点数
|
||||||
countNodes, err := models.SharedNodeDAO.CountAllEnabledNodes(tx)
|
countNodes, err := models.SharedNodeDAO.CountAllEnabledNodes(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.CountNodes = countNodes
|
result.CountNodes = countNodes
|
||||||
|
|
||||||
// 服务数
|
// 服务数
|
||||||
countServers, err := models.SharedServerDAO.CountAllEnabledServers(tx)
|
countServers, err := models.SharedServerDAO.CountAllEnabledServers(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.CountServers = countServers
|
result.CountServers = countServers
|
||||||
|
|
||||||
// 用户数
|
// 用户数
|
||||||
countUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, "")
|
countUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.CountUsers = countUsers
|
result.CountUsers = countUsers
|
||||||
|
|
||||||
// API节点数
|
// API节点数
|
||||||
countAPINodes, err := models.SharedAPINodeDAO.CountAllEnabledAPINodes(tx)
|
countAPINodes, err := models.SharedAPINodeDAO.CountAllEnabledAPINodes(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.CountAPINodes = countAPINodes
|
result.CountAPINodes = countAPINodes
|
||||||
|
|
||||||
// 数据库节点数
|
// 数据库节点数
|
||||||
countDBNodes, err := models.SharedDBNodeDAO.CountAllEnabledNodes(tx)
|
countDBNodes, err := models.SharedDBNodeDAO.CountAllEnabledNodes(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.CountDBNodes = countDBNodes
|
result.CountDBNodes = countDBNodes
|
||||||
|
|
||||||
// 用户节点数
|
// 用户节点数
|
||||||
countUserNodes, err := models.SharedUserNodeDAO.CountAllEnabledUserNodes(tx)
|
countUserNodes, err := models.SharedUserNodeDAO.CountAllEnabledUserNodes(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.CountUserNodes = countUserNodes
|
result.CountUserNodes = countUserNodes
|
||||||
|
|
||||||
// 按日流量统计
|
// 按日流量统计
|
||||||
dayFrom := timeutil.Format("Ymd", time.Now().AddDate(0, 0, -14))
|
dayFrom := timeutil.Format("Ymd", time.Now().AddDate(0, 0, -14))
|
||||||
@@ -528,9 +528,14 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, stat := range dailyTrafficStats {
|
for _, stat := range dailyTrafficStats {
|
||||||
resp.DailyTrafficStats = append(resp.DailyTrafficStats, &pb.ComposeAdminDashboardResponse_DailyTrafficStat{
|
result.DailyTrafficStats = append(result.DailyTrafficStats, &pb.ComposeAdminDashboardResponse_DailyTrafficStat{
|
||||||
Day: stat.Day,
|
Day: stat.Day,
|
||||||
Bytes: int64(stat.Bytes),
|
Bytes: int64(stat.Bytes),
|
||||||
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
|
CountRequests: int64(stat.CountRequests),
|
||||||
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,9 +547,14 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, stat := range hourlyTrafficStats {
|
for _, stat := range hourlyTrafficStats {
|
||||||
resp.HourlyTrafficStats = append(resp.HourlyTrafficStats, &pb.ComposeAdminDashboardResponse_HourlyTrafficStat{
|
result.HourlyTrafficStats = append(result.HourlyTrafficStats, &pb.ComposeAdminDashboardResponse_HourlyTrafficStat{
|
||||||
Hour: stat.Hour,
|
Hour: stat.Hour,
|
||||||
Bytes: int64(stat.Bytes),
|
Bytes: int64(stat.Bytes),
|
||||||
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
|
CountRequests: int64(stat.CountRequests),
|
||||||
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +574,7 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
upgradeInfo.CountNodes = countNodes
|
upgradeInfo.CountNodes = countNodes
|
||||||
resp.NodeUpgradeInfo = upgradeInfo
|
result.NodeUpgradeInfo = upgradeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监控节点升级信息
|
// 监控节点升级信息
|
||||||
@@ -577,7 +587,7 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
upgradeInfo.CountNodes = countNodes
|
upgradeInfo.CountNodes = countNodes
|
||||||
resp.MonitorNodeUpgradeInfo = upgradeInfo
|
result.MonitorNodeUpgradeInfo = upgradeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// 认证节点升级信息
|
// 认证节点升级信息
|
||||||
@@ -590,7 +600,7 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
upgradeInfo.CountNodes = countNodes
|
upgradeInfo.CountNodes = countNodes
|
||||||
resp.AuthorityNodeUpgradeInfo = upgradeInfo
|
result.AuthorityNodeUpgradeInfo = upgradeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户节点升级信息
|
// 用户节点升级信息
|
||||||
@@ -603,7 +613,7 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
upgradeInfo.CountNodes = countNodes
|
upgradeInfo.CountNodes = countNodes
|
||||||
resp.UserNodeUpgradeInfo = upgradeInfo
|
result.UserNodeUpgradeInfo = upgradeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// API节点升级信息
|
// API节点升级信息
|
||||||
@@ -616,7 +626,7 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
upgradeInfo.CountNodes = countNodes
|
upgradeInfo.CountNodes = countNodes
|
||||||
resp.ApiNodeUpgradeInfo = upgradeInfo
|
result.ApiNodeUpgradeInfo = upgradeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNS节点升级信息
|
// DNS节点升级信息
|
||||||
@@ -629,10 +639,45 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
upgradeInfo.CountNodes = countNodes
|
upgradeInfo.CountNodes = countNodes
|
||||||
resp.NsNodeUpgradeInfo = upgradeInfo
|
result.NsNodeUpgradeInfo = upgradeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
// 域名排行
|
||||||
|
topDomainStats, err := stats.SharedServerDomainHourlyStatDAO.FindTopDomainStats(tx, hourFrom, hourTo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, stat := range topDomainStats {
|
||||||
|
result.TopDomainStats = append(result.TopDomainStats, &pb.ComposeAdminDashboardResponse_DomainStat{
|
||||||
|
ServerId: int64(stat.ServerId),
|
||||||
|
Domain: stat.Domain,
|
||||||
|
CountRequests: int64(stat.CountRequests),
|
||||||
|
Bytes: int64(stat.Bytes),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 节点排行
|
||||||
|
topNodeStats, err := stats.SharedNodeTrafficHourlyStatDAO.FindTopNodeStats(tx, "node", hourFrom, hourTo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, stat := range topNodeStats {
|
||||||
|
nodeName, err := models.SharedNodeDAO.FindNodeName(tx, int64(stat.NodeId))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodeName) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
result.TopNodeStats = append(result.TopNodeStats, &pb.ComposeAdminDashboardResponse_NodeStat{
|
||||||
|
NodeId: int64(stat.NodeId),
|
||||||
|
NodeName: nodeName,
|
||||||
|
CountRequests: int64(stat.CountRequests),
|
||||||
|
Bytes: int64(stat.Bytes),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAdminTheme 修改管理员使用的界面风格
|
// UpdateAdminTheme 修改管理员使用的界面风格
|
||||||
|
|||||||
@@ -49,32 +49,32 @@ func (this *ServerDailyStatService) UploadServerDailyStats(ctx context.Context,
|
|||||||
// TODO 将来改成每小时入库一次
|
// TODO 将来改成每小时入库一次
|
||||||
for _, stat := range req.Stats {
|
for _, stat := range req.Stats {
|
||||||
// 总体流量(按天)
|
// 总体流量(按天)
|
||||||
err = stats.SharedTrafficDailyStatDAO.IncreaseDailyStat(tx, timeutil.FormatTime("Ymd", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests)
|
err = stats.SharedTrafficDailyStatDAO.IncreaseDailyStat(tx, timeutil.FormatTime("Ymd", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.AttackBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 总体统计(按小时)
|
// 总体统计(按小时)
|
||||||
err = stats.SharedTrafficHourlyStatDAO.IncreaseHourlyStat(tx, timeutil.FormatTime("YmdH", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests)
|
err = stats.SharedTrafficHourlyStatDAO.IncreaseHourlyStat(tx, timeutil.FormatTime("YmdH", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.AttackBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 节点流量
|
// 节点流量
|
||||||
if nodeId > 0 {
|
if nodeId > 0 {
|
||||||
err = stats.SharedNodeTrafficDailyStatDAO.IncreaseDailyStat(tx, clusterId, role, nodeId, timeutil.FormatTime("Ymd", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests)
|
err = stats.SharedNodeTrafficDailyStatDAO.IncreaseDailyStat(tx, clusterId, role, nodeId, timeutil.FormatTime("Ymd", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.AttackBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = stats.SharedNodeTrafficHourlyStatDAO.IncreaseHourlyStat(tx, clusterId, role, nodeId, timeutil.FormatTime("YmdH", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests)
|
err = stats.SharedNodeTrafficHourlyStatDAO.IncreaseHourlyStat(tx, clusterId, role, nodeId, timeutil.FormatTime("YmdH", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.AttackBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 集群流量
|
// 集群流量
|
||||||
if clusterId > 0 {
|
if clusterId > 0 {
|
||||||
err = stats.SharedNodeClusterTrafficDailyStatDAO.IncreaseDailyStat(tx, clusterId, timeutil.FormatTime("Ymd", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests)
|
err = stats.SharedNodeClusterTrafficDailyStatDAO.IncreaseDailyStat(tx, clusterId, timeutil.FormatTime("Ymd", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.AttackBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ func (this *ServerDailyStatService) UploadServerDailyStats(ctx context.Context,
|
|||||||
|
|
||||||
// 域名统计
|
// 域名统计
|
||||||
for _, stat := range req.DomainStats {
|
for _, stat := range req.DomainStats {
|
||||||
err := stats.SharedServerDomainHourlyStatDAO.IncreaseHourlyStat(tx, clusterId, nodeId, stat.ServerId, stat.Domain, timeutil.FormatTime("YmdH", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests)
|
err := stats.SharedServerDomainHourlyStatDAO.IncreaseHourlyStat(tx, clusterId, nodeId, stat.ServerId, stat.Domain, timeutil.FormatTime("YmdH", stat.CreatedAt), stat.Bytes, stat.CachedBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.AttackBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ func (this *ServerStatBoardService) ComposeServerStatNodeClusterBoard(ctx contex
|
|||||||
CachedBytes: int64(stat.CachedBytes),
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
CountCachedRequests: int64(stat.CountCachedRequests),
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +115,8 @@ func (this *ServerStatBoardService) ComposeServerStatNodeClusterBoard(ctx contex
|
|||||||
CachedBytes: int64(stat.CachedBytes),
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
CountCachedRequests: int64(stat.CountCachedRequests),
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +138,8 @@ func (this *ServerStatBoardService) ComposeServerStatNodeClusterBoard(ctx contex
|
|||||||
NodeName: nodeName,
|
NodeName: nodeName,
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
Bytes: int64(stat.Bytes),
|
Bytes: int64(stat.Bytes),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +154,8 @@ func (this *ServerStatBoardService) ComposeServerStatNodeClusterBoard(ctx contex
|
|||||||
Domain: stat.Domain,
|
Domain: stat.Domain,
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
Bytes: int64(stat.Bytes),
|
Bytes: int64(stat.Bytes),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,6 +454,8 @@ func (this *ServerStatBoardService) ComposeServerStatNodeBoard(ctx context.Conte
|
|||||||
CachedBytes: int64(stat.CachedBytes),
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
CountCachedRequests: int64(stat.CountCachedRequests),
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,6 +473,8 @@ func (this *ServerStatBoardService) ComposeServerStatNodeBoard(ctx context.Conte
|
|||||||
CachedBytes: int64(stat.CachedBytes),
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
CountCachedRequests: int64(stat.CountCachedRequests),
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,6 +693,8 @@ func (this *ServerStatBoardService) ComposeServerStatBoard(ctx context.Context,
|
|||||||
CachedBytes: int64(stat.CachedBytes),
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
CountCachedRequests: int64(stat.CountCachedRequests),
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,6 +712,8 @@ func (this *ServerStatBoardService) ComposeServerStatBoard(ctx context.Context,
|
|||||||
CachedBytes: int64(stat.CachedBytes),
|
CachedBytes: int64(stat.CachedBytes),
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
CountCachedRequests: int64(stat.CountCachedRequests),
|
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,6 +728,8 @@ func (this *ServerStatBoardService) ComposeServerStatBoard(ctx context.Context,
|
|||||||
Domain: stat.Domain,
|
Domain: stat.Domain,
|
||||||
CountRequests: int64(stat.CountRequests),
|
CountRequests: int64(stat.CountRequests),
|
||||||
Bytes: int64(stat.Bytes),
|
Bytes: int64(stat.Bytes),
|
||||||
|
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||||
|
AttackBytes: int64(stat.AttackBytes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user