Consolidate getMemoryStats (#1122)

* Consolidate getMemoryStats

* Avoid divide-by-0
This commit is contained in:
Raja Subramanian
2022-10-26 09:16:39 +05:30
committed by GitHub
parent 7a7fc09372
commit 1e8cc0dc76
4 changed files with 33 additions and 22 deletions
-11
View File
@@ -7,7 +7,6 @@ import (
"sync"
"github.com/mackerelio/go-osstat/cpu"
"github.com/mackerelio/go-osstat/memory"
)
var (
@@ -35,16 +34,6 @@ func getCPUStats() (cpuLoad float32, numCPUs uint32, err error) {
return
}
func getMemoryStats() (memoryLoad float32, err error) {
memInfo, err := memory.Get()
if err != nil {
return
}
memoryLoad = float32(memInfo.Used) / float32(memInfo.Total)
return
}
func getTCStats() (packets, drops uint32, err error) {
// linux only
return