网站看板数据中增加当日独立IP和当日流量

This commit is contained in:
GoEdgeLab
2024-04-12 18:51:42 +08:00
parent 416cf4981d
commit 3b3763d35b
5 changed files with 128 additions and 24 deletions

View File

@@ -66,7 +66,7 @@ func init() {
// 更新网站的带宽峰值
if stat.ServerId > 0 {
// 更新带宽统计
err = models.SharedServerBandwidthStatDAO.UpdateServerBandwidth(tx, stat.UserId, stat.ServerId, stat.NodeRegionId, stat.UserPlanId, 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.UserPlanId, stat.Day, stat.TimeAt, stat.Bytes, stat.TotalBytes, stat.CachedBytes, stat.AttackBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.CountIPs)
if err != nil {
remotelogs.Error("ServerBandwidthStatService", "dump bandwidth stats failed: "+err.Error())
}
@@ -147,6 +147,7 @@ func (this *ServerBandwidthStatService) UploadServerBandwidthStats(ctx context.C
oldStat.CountCachedRequests += stat.CountCachedRequests
oldStat.CountAttackRequests += stat.CountAttackRequests
oldStat.CountWebsocketConnections += stat.CountWebsocketConnections
oldStat.CountIPs += stat.CountIPs
} else {
serverBandwidthStatsMap[key] = &pb.ServerBandwidthStat{
Id: 0,
@@ -164,6 +165,7 @@ func (this *ServerBandwidthStatService) UploadServerBandwidthStats(ctx context.C
CountAttackRequests: stat.CountAttackRequests,
CountWebsocketConnections: stat.CountWebsocketConnections,
UserPlanId: stat.UserPlanId,
CountIPs: stat.CountIPs,
}
}
serverBandwidthStatsLocker.Unlock()

View File

@@ -471,6 +471,17 @@ func (this *ServerStatBoardService) ComposeServerStatBoard(ctx context.Context,
}
}
// 当日统计
{
var day = timeutil.Format("Ymd")
stat, err := models.SharedServerBandwidthStatDAO.SumDailyStat(tx, req.ServerId, 0, day, day)
if err != nil {
return nil, err
}
result.DailyCountIPs = stat.CountIPs
result.DailyTrafficBytes = stat.Bytes
}
// 带宽统计
{
var month = timeutil.Format("Ym")