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
@@ -9,7 +9,6 @@ import (
"github.com/florianl/go-tc"
"github.com/mackerelio/go-osstat/cpu"
"github.com/mackerelio/go-osstat/memory"
)
var (
@@ -37,16 +36,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) {
rtnl, err := tc.Open(&tc.Config{})
if err != nil {