mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-05 12:31:49 +02:00
more updates
This commit is contained in:
10
agent/pve.go
10
agent/pve.go
@@ -82,14 +82,18 @@ func (pm *pveManager) getPVEStats() ([]*container.PveNodeStats, error) {
|
||||
var sent_delta, recv_delta float64
|
||||
if initialized {
|
||||
secondsElapsed := time.Since(resourceStats.PrevReadTime).Seconds()
|
||||
sent_delta = float64(total_sent-resourceStats.PrevNet.Sent) / secondsElapsed
|
||||
recv_delta = float64(total_recv-resourceStats.PrevNet.Recv) / secondsElapsed
|
||||
if secondsElapsed > 0 {
|
||||
sent_delta = float64(total_sent-resourceStats.PrevNet.Sent) / secondsElapsed
|
||||
recv_delta = float64(total_recv-resourceStats.PrevNet.Recv) / secondsElapsed
|
||||
}
|
||||
}
|
||||
resourceStats.PrevNet.Sent = total_sent
|
||||
resourceStats.PrevNet.Recv = total_recv
|
||||
resourceStats.PrevReadTime = time.Now()
|
||||
|
||||
// Update final stats values
|
||||
resourceStats.Cpu = twoDecimals(100.0 * resource.CPU * float64(resource.MaxCPU) / float64(pm.cpuCount))
|
||||
resourceStats.Mem = float64(resource.Mem)
|
||||
resourceStats.Mem = bytesToMegabytes(float64(resource.Mem))
|
||||
resourceStats.Bandwidth = [2]uint64{uint64(sent_delta), uint64(recv_delta)}
|
||||
|
||||
stats = append(stats, resourceStats)
|
||||
|
||||
Reference in New Issue
Block a user