网站列表增加QPS和攻击QPS信息

This commit is contained in:
刘祥超
2023-07-07 18:51:36 +08:00
parent 87a81f59c7
commit ac19f06b6c
5 changed files with 98 additions and 9 deletions

View File

@@ -1301,6 +1301,14 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
order = "trafficOutAsc"
} else if req.TrafficOutDesc {
order = "trafficOutDesc"
} else if req.RequestsAsc {
order = "requestsAsc"
} else if req.RequestsDesc {
order = "requestsDesc"
} else if req.AttackRequestsAsc {
order = "attackRequestsAsc"
} else if req.AttackRequestsDesc {
order = "attackRequestsDesc"
}
servers, err := models.SharedServerDAO.ListEnabledServersMatch(tx, req.Offset, req.Size, req.ServerGroupId, req.Keyword, req.UserId, req.NodeClusterId, req.AuditingFlag, utils.SplitStrings(req.ProtocolFamily, ","), order)
@@ -1418,11 +1426,13 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
Id: int64(server.ClusterId),
Name: clusterName,
},
ServerGroups: pbGroups,
UserId: int64(server.UserId),
User: pbUser,
BandwidthTime: server.BandwidthTime,
BandwidthBytes: int64(server.BandwidthBytes),
ServerGroups: pbGroups,
UserId: int64(server.UserId),
User: pbUser,
BandwidthTime: server.BandwidthTime,
BandwidthBytes: int64(server.BandwidthBytes),
CountRequests: int64(server.CountRequests),
CountAttackRequests: int64(server.CountAttackRequests),
})
}

View File

@@ -65,12 +65,12 @@ func init() {
for _, stat := range m {
// 更新服务的带宽峰值
if stat.ServerId > 0 {
err := models.SharedServerBandwidthStatDAO.UpdateServerBandwidth(tx, stat.UserId, stat.ServerId, stat.NodeRegionId, stat.Day, stat.TimeAt, stat.Bytes, stat.TotalBytes, stat.CachedBytes, stat.AttackBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests)
err = models.SharedServerBandwidthStatDAO.UpdateServerBandwidth(tx, stat.UserId, stat.ServerId, stat.NodeRegionId, stat.Day, stat.TimeAt, stat.Bytes, stat.TotalBytes, stat.CachedBytes, stat.AttackBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests)
if err != nil {
remotelogs.Error("ServerBandwidthStatService", "dump bandwidth stats failed: "+err.Error())
}
err = models.SharedServerDAO.UpdateServerBandwidth(tx, stat.ServerId, stat.Day+stat.TimeAt, stat.Bytes)
err = models.SharedServerDAO.UpdateServerBandwidth(tx, stat.ServerId, stat.Day+stat.TimeAt, stat.Bytes, stat.CountRequests, stat.CountAttackRequests)
if err != nil {
remotelogs.Error("ServerBandwidthStatService", "update server bandwidth failed: "+err.Error())
}