diff --git a/agent/disk.go b/agent/disk.go index 52f018066..e7276314e 100644 --- a/agent/disk.go +++ b/agent/disk.go @@ -596,7 +596,6 @@ func (a *Agent) initializeDiskIoStats(diskIoCounters map[string]disk.IOCountersS continue } // populate initial values - stats.Time = now stats.TotalRead = d.ReadBytes stats.TotalWrite = d.WriteBytes 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)) } - // Update global fsStats baseline for cross-interval correctness + // Update the baseline that seeds new intervals a.setDiskBaseline(name, prevDiskFromCounter(d, now)) - stats.Time = now stats.TotalRead = d.ReadBytes stats.TotalWrite = d.WriteBytes stats.DiskReadPs = readMbPerSecond diff --git a/agent/disk_test.go b/agent/disk_test.go index f37f64f6e..487f16973 100644 --- a/agent/disk_test.go +++ b/agent/disk_test.go @@ -1032,8 +1032,10 @@ func TestInitializeDiskIoStatsResetsTrackedDevices(t *testing.T) { assert.Len(t, agent.fsNames, 2) assert.Equal(t, uint64(10), agent.fsStats["sda"].TotalRead) assert.Equal(t, uint64(20), agent.fsStats["sda"].TotalWrite) - assert.False(t, agent.fsStats["sda"].Time.IsZero()) - assert.False(t, agent.fsStats["sdb"].Time.IsZero()) + assert.Equal(t, uint64(10), agent.diskBaseline["sda"].readBytes) + 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{ "sdb": {Name: "sdb", ReadBytes: 50, WriteBytes: 60}, diff --git a/internal/entities/system/system.go b/internal/entities/system/system.go index aeaf78997..7ef366165 100644 --- a/internal/entities/system/system.go +++ b/internal/entities/system/system.go @@ -110,18 +110,17 @@ type GPUData struct { } type FsStats struct { - Time time.Time `json:"-"` - Root bool `json:"-"` - Mountpoint string `json:"-"` - Name string `json:"-"` - DiskTotal float64 `json:"d" cbor:"0,keyasint"` - DiskUsed float64 `json:"du" cbor:"1,keyasint"` - 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 - DiskReadPs float64 `json:"r" cbor:"2,keyasint"` - DiskWritePs float64 `json:"w" cbor:"3,keyasint"` - MaxDiskReadPS float64 `json:"rm,omitempty" cbor:"-"` - MaxDiskWritePS float64 `json:"wm,omitempty" cbor:"-"` + Root bool `json:"-"` + Mountpoint string `json:"-"` + Name string `json:"-"` + DiskTotal float64 `json:"d" cbor:"0,keyasint"` + DiskUsed float64 `json:"du" cbor:"1,keyasint"` + 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 + DiskReadPs float64 `json:"r" cbor:"2,keyasint"` + DiskWritePs float64 `json:"w" cbor:"3,keyasint"` + MaxDiskReadPS float64 `json:"rm,omitempty" cbor:"-"` + MaxDiskWritePS float64 `json:"wm,omitempty" cbor:"-"` // TODO: remove DiskReadPs and DiskWritePs in future release in favor of DiskReadBytes and DiskWriteBytes DiskReadBytes uint64 `json:"rb" cbor:"6,keyasint,omitempty"` DiskWriteBytes uint64 `json:"wb" cbor:"7,keyasint,omitempty"`