diff --git a/pkg/snclient/check_drive_io_windows.go b/pkg/snclient/check_drive_io_windows.go index 032bf638..db468633 100644 --- a/pkg/snclient/check_drive_io_windows.go +++ b/pkg/snclient/check_drive_io_windows.go @@ -6,7 +6,9 @@ import ( "maps" "time" + "github.com/consol-monitoring/snclient/pkg/convert" "github.com/consol-monitoring/snclient/pkg/counter" + "github.com/consol-monitoring/snclient/pkg/humanize" "github.com/shirou/gopsutil/v4/disk" ) @@ -30,6 +32,10 @@ func (l *CheckDriveIO) buildEntry(snc *Agent, diskIOCounters any, deviceLogicalN return false } + // Windows IoCountersStat does not return a Label + // Might have to find it somewhere else + entry["label"] = "" + // counters use this format when saving metrics // found in CheckSystemHandler.addLinuxDiskStats counterCategory := "disk_" + counters.Name @@ -38,12 +44,18 @@ func (l *CheckDriveIO) buildEntry(snc *Agent, diskIOCounters any, deviceLogicalN l.addRateToEntry(snc, entry, "read_count_rate", counterCategory, "read_count") entry["read_bytes"] = fmt.Sprintf("%d", counters.ReadBytes) l.addRateToEntry(snc, entry, "read_bytes_rate", counterCategory, "read_bytes") + readBytesRateFloat64 := convert.Float64(entry["read_bytes_rate"]) + humanizedReadBytesRate := humanize.IBytesF(uint64(readBytesRateFloat64), 1) + entry["read_bytes_rate_humanized"] = humanizedReadBytesRate + "/s" entry["read_time"] = fmt.Sprintf("%f", counters.ReadTime) entry["write_count"] = fmt.Sprintf("%d", counters.WriteCount) l.addRateToEntry(snc, entry, "write_count_rate", counterCategory, "write_count") entry["write_bytes"] = fmt.Sprintf("%d", counters.WriteBytes) l.addRateToEntry(snc, entry, "write_bytes_rate", counterCategory, "write_bytes") + writeBytesRateFloat64 := convert.Float64(entry["write_bytes_rate"]) + humanizedWriteBytesRate := humanize.IBytesF(uint64(writeBytesRateFloat64), 1) + entry["write_bytes_rate_humanized"] = humanizedWriteBytesRate + "/s" entry["write_time"] = fmt.Sprintf("%f", counters.WriteTime) entry["idle_time"] = fmt.Sprintf("%d", counters.IdleTime) diff --git a/pkg/snclient/task_check_system_windows.go b/pkg/snclient/task_check_system_windows.go index 663b3bcf..59727896 100644 --- a/pkg/snclient/task_check_system_windows.go +++ b/pkg/snclient/task_check_system_windows.go @@ -373,12 +373,12 @@ func (c *CheckSystemHandler) addDiskStats(create bool) { c.snc.Counter.Set(category, "write_count", float64(diskIOCounters[diskName].WriteCount)) c.snc.Counter.Set(category, "read_bytes", float64(diskIOCounters[diskName].ReadBytes)) c.snc.Counter.Set(category, "read_count", float64(diskIOCounters[diskName].ReadCount)) - c.snc.Counter.Set(category, "idle_time", float64(diskIOCounters[diskName].IdleTime)) - // important to put the query_time in uint64 form + // important to put the query_time and idle_time uint64 form // it is some kind of nanosecond counter starting from long ago // even current values on 2026, the value has log2 around 56 // float64 has 53 bits of significant precision, it loses precision // makes calculating utilization impossible + c.snc.Counter.Set(category, "idle_time", diskIOCounters[diskName].IdleTime) c.snc.Counter.Set(category, "query_time", diskIOCounters[diskName].QueryTime) } }