mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-15 00:30:24 +08:00
上传带宽信息时附带区域ID信息
This commit is contained in:
@@ -3,9 +3,8 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/events"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/goman"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/rpc"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
@@ -19,14 +18,6 @@ var SharedBandwidthStatManager = NewBandwidthStatManager()
|
||||
|
||||
const bandwidthTimestampDelim = 2 // N秒平均,更为精确
|
||||
|
||||
func init() {
|
||||
events.On(events.EventLoaded, func() {
|
||||
goman.New(func() {
|
||||
SharedBandwidthStatManager.Start()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
type BandwidthStat struct {
|
||||
Day string
|
||||
TimeAt string
|
||||
@@ -65,6 +56,12 @@ func (this *BandwidthStatManager) Start() {
|
||||
}
|
||||
|
||||
func (this *BandwidthStatManager) Loop() error {
|
||||
var regionId int64
|
||||
nodeConfig, _ := nodeconfigs.SharedNodeConfig()
|
||||
if nodeConfig != nil {
|
||||
regionId = nodeConfig.RegionId
|
||||
}
|
||||
|
||||
var now = time.Now()
|
||||
var day = timeutil.Format("Ymd", now)
|
||||
var currentTime = timeutil.FormatTime("Hi", now.Unix()/300*300)
|
||||
@@ -86,6 +83,7 @@ func (this *BandwidthStatManager) Loop() error {
|
||||
Day: stat.Day,
|
||||
TimeAt: stat.TimeAt,
|
||||
Bytes: stat.MaxBytes / bandwidthTimestampDelim,
|
||||
RegionId: regionId,
|
||||
})
|
||||
delete(this.m, key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user