summaryrefslogtreecommitdiff
path: root/internal/display/tooltip.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/display/tooltip.go')
-rw-r--r--internal/display/tooltip.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/display/tooltip.go b/internal/display/tooltip.go
index e612b2c..9dec4f2 100644
--- a/internal/display/tooltip.go
+++ b/internal/display/tooltip.go
@@ -38,6 +38,8 @@ func tooltipLines(bar *barDescriptor, snap map[string]*stats.HostStats, cfg *con
return netTooltipLines(bar, cfg, state)
case barLoad:
return loadTooltipLines(bar, h, cfg, state)
+ case barDisk:
+ return diskTooltipLines(bar, h, cfg, state)
}
return nil
}
@@ -126,6 +128,40 @@ func loadTooltipLines(bar *barDescriptor, h *stats.HostStats, cfg *config.Config
return lines
}
+// diskTooltipLines returns tooltip text for a disk bar showing read/write throughput
+// and utilization %.
+func diskTooltipLines(bar *barDescriptor, h *stats.HostStats, cfg *config.Config, state *runState) []string {
+ label := bar.diskName
+ if label == "" {
+ label = "all"
+ }
+ lines := []string{fmt.Sprintf("%s [disk:%s]", bar.host, label)}
+ key := bar.host + ";disk;" + label
+ sm := state.smoothedDisk[key]
+ if sm == nil {
+ lines = append(lines, "No data yet")
+ return lines
+ }
+ // Compute MB/s from smoothed percentages and current peak
+ peak := state.diskPeak
+ if peak <= 0 {
+ peak = 1048576
+ }
+ readMBs := sm.readPct / 100 * peak / 1048576
+ writeMBs := sm.writePct / 100 * peak / 1048576
+
+ scaleLabel := "Peak: "
+ if cfg.DiskMax > 0 {
+ scaleLabel = "Max: "
+ }
+ lines = append(lines,
+ fmt.Sprintf("Read: %6.2f MB/s", readMBs),
+ fmt.Sprintf("Write: %6.2f MB/s", writeMBs),
+ fmt.Sprintf(scaleLabel+"%6.2f MB/s", peak/1048576),
+ )
+ return lines
+}
+
// formatKB formats a value in KB as a human-readable string (KB, MB, or GB).
func formatKB(kb int64) string {
switch {