mirror of
https://github.com/fankes/komari-agent.git
synced 2025-12-11 16:03:39 +08:00
fix: 流量上一个重置日期
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/komari-monitor/komari-agent/cmd/flags"
|
||||
"github.com/komari-monitor/komari-agent/monitoring/netstatic"
|
||||
"github.com/komari-monitor/komari-agent/utils"
|
||||
"github.com/shirou/gopsutil/v4/net"
|
||||
)
|
||||
|
||||
@@ -133,8 +134,8 @@ func NetworkSpeed() (totalUp, totalDown, upSpeed, downSpeed uint64, err error) {
|
||||
if flags.MonthRotate != 0 {
|
||||
netstatic.StartOrContinue() // 确保netstatic在运行
|
||||
now := uint64(time.Now().Unix())
|
||||
aMonthAgo := now - uint64(30*24*3600)
|
||||
nicStatics, err := netstatic.GetTotalTrafficBetween(aMonthAgo, now)
|
||||
resetDay := uint64(utils.GetLastResetDate(flags.MonthRotate, time.Now()).Unix())
|
||||
nicStatics, err := netstatic.GetTotalTrafficBetween(resetDay, now)
|
||||
if err != nil {
|
||||
// 如果netstatic失败,回退到原来的方法,并返回额外的错误信息
|
||||
fallbackUp, fallbackDown, fallbackUpSpeed, fallbackDownSpeed, fallbackErr := getNetworkSpeedFallback(includeNics, excludeNics)
|
||||
|
||||
Reference in New Issue
Block a user