mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-03 07:00:26 +08:00
服务列表增加下行带宽
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models/stats"
|
||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
"math"
|
||||
"time"
|
||||
@@ -220,3 +221,36 @@ func (this *ServerDailyStatService) FindLatestServerDailyStats(ctx context.Conte
|
||||
}
|
||||
return &pb.FindLatestServerDailyStatsResponse{Stats: result}, nil
|
||||
}
|
||||
|
||||
// SumCurrentServerDailyStats 查找单个服务当前统计数据
|
||||
func (this *ServerDailyStatService) SumCurrentServerDailyStats(ctx context.Context, req *pb.SumCurrentServerDailyStatsRequest) (*pb.SumCurrentServerDailyStatsResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tx *dbs.Tx
|
||||
stat, err := models.SharedServerDailyStatDAO.SumCurrentDailyStat(tx, req.ServerId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pbStat = &pb.ServerDailyStat{
|
||||
ServerId: req.ServerId,
|
||||
}
|
||||
if stat != nil {
|
||||
pbStat = &pb.ServerDailyStat{
|
||||
ServerId: req.ServerId,
|
||||
Bytes: int64(stat.Bytes),
|
||||
CachedBytes: int64(stat.CachedBytes),
|
||||
CountRequests: int64(stat.CountRequests),
|
||||
CountCachedRequests: int64(stat.CountCachedRequests),
|
||||
CountAttackRequests: int64(stat.CountAttackRequests),
|
||||
AttackBytes: int64(stat.AttackBytes),
|
||||
}
|
||||
}
|
||||
|
||||
return &pb.SumCurrentServerDailyStatsResponse{
|
||||
ServerDailyStat: pbStat,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user