mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-21 08:57:48 +02:00
feat: Add cumulative disk read/write totals to Disk I/O sheet (#2179)
This commit is contained in:
@@ -52,6 +52,7 @@ type Stats struct {
|
||||
CpuCoresUsage Uint8Slice `json:"cpus,omitempty" cbor:"34,keyasint,omitempty"` // per-core busy usage [CPU0..]
|
||||
DiskIoStats [6]float64 `json:"dios,omitzero" cbor:"35,keyasint,omitzero"` // [read time %, write time %, io utilization %, r_await ms, w_await ms, weighted io %]
|
||||
MaxDiskIoStats [6]float64 `json:"diosm,omitzero" cbor:"-"` // max values for DiskIoStats
|
||||
DiskIOTotal [2]uint64 `json:"diot,omitzero" cbor:"38,keyasint,omitzero"` // [total read bytes, total write bytes] cumulative device counters
|
||||
}
|
||||
|
||||
// Uint8Slice wraps []uint8 to customize JSON encoding while keeping CBOR efficient.
|
||||
@@ -99,8 +100,8 @@ type FsStats struct {
|
||||
Name string `json:"-"`
|
||||
DiskTotal float64 `json:"d" cbor:"0,keyasint"`
|
||||
DiskUsed float64 `json:"du" cbor:"1,keyasint"`
|
||||
TotalRead uint64 `json:"-"`
|
||||
TotalWrite uint64 `json:"-"`
|
||||
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:"-"`
|
||||
|
||||
@@ -35,6 +35,20 @@ func TestStatsBatteryTransport(t *testing.T) {
|
||||
assert.Equal(t, stats.Batteries, decoded.Batteries)
|
||||
}
|
||||
|
||||
func TestStatsDiskIOTotalAndFansTransport(t *testing.T) {
|
||||
stats := Stats{
|
||||
DiskIOTotal: [2]uint64{437348527104, 331522465792},
|
||||
Fans: map[string]uint16{"cpu": 1200},
|
||||
}
|
||||
|
||||
cborData, err := cbor.Marshal(stats)
|
||||
require.NoError(t, err)
|
||||
var decoded Stats
|
||||
require.NoError(t, cbor.Unmarshal(cborData, &decoded))
|
||||
assert.Equal(t, stats.DiskIOTotal, decoded.DiskIOTotal)
|
||||
assert.Equal(t, stats.Fans, decoded.Fans)
|
||||
}
|
||||
|
||||
func TestStatsBatteryNumericArrayUnmarshal(t *testing.T) {
|
||||
var stats Stats
|
||||
require.NoError(t, json.Unmarshal([]byte(`{"bat":[50,4]}`), &stats))
|
||||
|
||||
Reference in New Issue
Block a user