mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-30 05:17:49 +02:00
refactor(agent): remove unused FsStats.Time
The disk I/O seed now reads from diskBaseline, so nothing reads FsStats.Time anymore.
This commit is contained in:
@@ -596,7 +596,6 @@ func (a *Agent) initializeDiskIoStats(diskIoCounters map[string]disk.IOCountersS
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// populate initial values
|
// populate initial values
|
||||||
stats.Time = now
|
|
||||||
stats.TotalRead = d.ReadBytes
|
stats.TotalRead = d.ReadBytes
|
||||||
stats.TotalWrite = d.WriteBytes
|
stats.TotalWrite = d.WriteBytes
|
||||||
a.setDiskBaseline(device, prevDiskFromCounter(d, now))
|
a.setDiskBaseline(device, prevDiskFromCounter(d, now))
|
||||||
@@ -742,9 +741,8 @@ func (a *Agent) updateDiskIo(cacheTimeMs uint16, systemStats *system.Stats) {
|
|||||||
wAwait = utils.TwoDecimals(float64(deltaWriteTime) / float64(deltaWriteCount))
|
wAwait = utils.TwoDecimals(float64(deltaWriteTime) / float64(deltaWriteCount))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update global fsStats baseline for cross-interval correctness
|
// Update the baseline that seeds new intervals
|
||||||
a.setDiskBaseline(name, prevDiskFromCounter(d, now))
|
a.setDiskBaseline(name, prevDiskFromCounter(d, now))
|
||||||
stats.Time = now
|
|
||||||
stats.TotalRead = d.ReadBytes
|
stats.TotalRead = d.ReadBytes
|
||||||
stats.TotalWrite = d.WriteBytes
|
stats.TotalWrite = d.WriteBytes
|
||||||
stats.DiskReadPs = readMbPerSecond
|
stats.DiskReadPs = readMbPerSecond
|
||||||
|
|||||||
@@ -1032,8 +1032,10 @@ func TestInitializeDiskIoStatsResetsTrackedDevices(t *testing.T) {
|
|||||||
assert.Len(t, agent.fsNames, 2)
|
assert.Len(t, agent.fsNames, 2)
|
||||||
assert.Equal(t, uint64(10), agent.fsStats["sda"].TotalRead)
|
assert.Equal(t, uint64(10), agent.fsStats["sda"].TotalRead)
|
||||||
assert.Equal(t, uint64(20), agent.fsStats["sda"].TotalWrite)
|
assert.Equal(t, uint64(20), agent.fsStats["sda"].TotalWrite)
|
||||||
assert.False(t, agent.fsStats["sda"].Time.IsZero())
|
assert.Equal(t, uint64(10), agent.diskBaseline["sda"].readBytes)
|
||||||
assert.False(t, agent.fsStats["sdb"].Time.IsZero())
|
assert.Equal(t, uint64(40), agent.diskBaseline["sdb"].writeBytes)
|
||||||
|
assert.False(t, agent.diskBaseline["sda"].at.IsZero())
|
||||||
|
assert.False(t, agent.diskBaseline["sdb"].at.IsZero())
|
||||||
|
|
||||||
agent.initializeDiskIoStats(map[string]disk.IOCountersStat{
|
agent.initializeDiskIoStats(map[string]disk.IOCountersStat{
|
||||||
"sdb": {Name: "sdb", ReadBytes: 50, WriteBytes: 60},
|
"sdb": {Name: "sdb", ReadBytes: 50, WriteBytes: 60},
|
||||||
|
|||||||
@@ -110,18 +110,17 @@ type GPUData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FsStats struct {
|
type FsStats struct {
|
||||||
Time time.Time `json:"-"`
|
Root bool `json:"-"`
|
||||||
Root bool `json:"-"`
|
Mountpoint string `json:"-"`
|
||||||
Mountpoint string `json:"-"`
|
Name string `json:"-"`
|
||||||
Name string `json:"-"`
|
DiskTotal float64 `json:"d" cbor:"0,keyasint"`
|
||||||
DiskTotal float64 `json:"d" cbor:"0,keyasint"`
|
DiskUsed float64 `json:"du" cbor:"1,keyasint"`
|
||||||
DiskUsed float64 `json:"du" cbor:"1,keyasint"`
|
TotalRead uint64 `json:"tr,omitzero" cbor:"9,keyasint,omitzero"` // cumulative device read bytes
|
||||||
TotalRead uint64 `json:"tr,omitzero" cbor:"9,keyasint,omitzero"` // cumulative device read bytes
|
TotalWrite uint64 `json:"tw,omitzero" cbor:"10,keyasint,omitzero"` // cumulative device write bytes
|
||||||
TotalWrite uint64 `json:"tw,omitzero" cbor:"10,keyasint,omitzero"` // cumulative device write bytes
|
DiskReadPs float64 `json:"r" cbor:"2,keyasint"`
|
||||||
DiskReadPs float64 `json:"r" cbor:"2,keyasint"`
|
DiskWritePs float64 `json:"w" cbor:"3,keyasint"`
|
||||||
DiskWritePs float64 `json:"w" cbor:"3,keyasint"`
|
MaxDiskReadPS float64 `json:"rm,omitempty" cbor:"-"`
|
||||||
MaxDiskReadPS float64 `json:"rm,omitempty" cbor:"-"`
|
MaxDiskWritePS float64 `json:"wm,omitempty" cbor:"-"`
|
||||||
MaxDiskWritePS float64 `json:"wm,omitempty" cbor:"-"`
|
|
||||||
// TODO: remove DiskReadPs and DiskWritePs in future release in favor of DiskReadBytes and DiskWriteBytes
|
// TODO: remove DiskReadPs and DiskWritePs in future release in favor of DiskReadBytes and DiskWriteBytes
|
||||||
DiskReadBytes uint64 `json:"rb" cbor:"6,keyasint,omitempty"`
|
DiskReadBytes uint64 `json:"rb" cbor:"6,keyasint,omitempty"`
|
||||||
DiskWriteBytes uint64 `json:"wb" cbor:"7,keyasint,omitempty"`
|
DiskWriteBytes uint64 `json:"wb" cbor:"7,keyasint,omitempty"`
|
||||||
|
|||||||
Reference in New Issue
Block a user