Alpha (#490)
* feat: add memory status for snapshot * feat: add memory status for snapshot
This commit is contained in:
parent
eb07aafce8
commit
36b3581389
1 changed files with 9 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package statistic
|
package statistic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -61,10 +62,17 @@ func (m *Manager) Snapshot() *Snapshot {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
getMem := func() uint64 {
|
||||||
|
var memStats runtime.MemStats
|
||||||
|
runtime.ReadMemStats(&memStats)
|
||||||
|
return memStats.StackInuse + memStats.HeapInuse + memStats.HeapIdle - memStats.HeapReleased
|
||||||
|
}
|
||||||
|
|
||||||
return &Snapshot{
|
return &Snapshot{
|
||||||
UploadTotal: m.uploadTotal.Load(),
|
UploadTotal: m.uploadTotal.Load(),
|
||||||
DownloadTotal: m.downloadTotal.Load(),
|
DownloadTotal: m.downloadTotal.Load(),
|
||||||
Connections: connections,
|
Connections: connections,
|
||||||
|
Memory: getMem(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,4 +100,5 @@ type Snapshot struct {
|
||||||
DownloadTotal int64 `json:"downloadTotal"`
|
DownloadTotal int64 `json:"downloadTotal"`
|
||||||
UploadTotal int64 `json:"uploadTotal"`
|
UploadTotal int64 `json:"uploadTotal"`
|
||||||
Connections []tracker `json:"connections"`
|
Connections []tracker `json:"connections"`
|
||||||
|
Memory uint64 `json:"memory"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue