mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 16:45:07 +00:00
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.
This commit is contained in:
@@ -212,6 +212,14 @@ func animTickWithSpeed(cpuUsage float64) tea.Cmd {
|
||||
// runJSONMode collects metrics once and outputs as JSON.
|
||||
func runJSONMode() {
|
||||
collector := NewCollector()
|
||||
|
||||
// First collection initializes network state (returns nil for network)
|
||||
_, _ = collector.Collect()
|
||||
|
||||
// Wait 1 second for network rate calculation
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
// Second collection has actual network data
|
||||
data, err := collector.Collect()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error collecting metrics: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user