Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/snclient/check_drive_io_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/snclient/task_check_system_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Loading