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