Skip to content

Commit fbaf5e7

Browse files
authored
fix(status): enable network data in JSON mode (#532)
Network rate calculation requires two samples to compute the delta. In JSON mode, the collector was only called once, causing the network field to always return nil. This change adds a second collection call with a 1-second interval, allowing the network rates to be calculated properly.
1 parent 6843073 commit fbaf5e7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/status/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ func animTickWithSpeed(cpuUsage float64) tea.Cmd {
212212
// runJSONMode collects metrics once and outputs as JSON.
213213
func runJSONMode() {
214214
collector := NewCollector()
215+
216+
// First collection initializes network state (returns nil for network)
217+
_, _ = collector.Collect()
218+
219+
// Wait 1 second for network rate calculation
220+
time.Sleep(1 * time.Second)
221+
222+
// Second collection has actual network data
215223
data, err := collector.Collect()
216224
if err != nil {
217225
fmt.Fprintf(os.Stderr, "error collecting metrics: %v\n", err)

0 commit comments

Comments
 (0)