diff --git a/csv.go b/csv.go index 5cabd11..3d99dce 100644 --- a/csv.go +++ b/csv.go @@ -29,7 +29,7 @@ func NewCSVDump() (*CSVDump, error) { } // Adds adds new CPU value to the CSV dump. -func (c *CSVDump) Add(value float64) { +func (c *CSVDump) Add(cpu float64, rx, tx int64) { fd, err := os.OpenFile(c.file, os.O_APPEND|os.O_WRONLY|os.O_SYNC, 0644) if err != nil { // we just created this file, it should not dissapear :D @@ -38,6 +38,6 @@ func (c *CSVDump) Add(value float64) { now := time.Now() - fd.WriteString(fmt.Sprintf("%d,%f\n", now.Unix(), value)) + fd.WriteString(fmt.Sprintf("%d,%f,%d,%d\n", now.Unix(), cpu, rx, tx)) fd.Close() } diff --git a/main.go b/main.go index d7631aa..4e5e565 100644 --- a/main.go +++ b/main.go @@ -86,9 +86,6 @@ func main() { // update data data.AddCPUValue(cpu) - if *csvdump { - csv.Add(cpu) - } // netstats rx, tx, err := src.Netstats() @@ -101,6 +98,11 @@ func main() { data.AddNetworkStats(rx, tx) + // csv + if *csvdump { + csv.Add(cpu, rx, tx) + } + ui.UpdateCPU(data.CPU()) ui.UpdateNetstats(data.NetworkStats()) ui.Render()