Populate memory load in node stats. (#1121)
This commit is contained in:
@@ -95,6 +95,10 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats, prevAverage *livekit.NodeStats
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
memoryLoad, _ := getMemoryStats()
|
||||
// On MacOS, get "\"vm_stat\": executable file not found in $PATH" although it is in /usr/bin
|
||||
// So, do not error out. Use the information if it is available.
|
||||
|
||||
sysPackets, sysDroppedPackets, err := getTCStats()
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -154,6 +158,7 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats, prevAverage *livekit.NodeStats
|
||||
LoadAvgLast15Min: float32(loadAvg.Loadavg15),
|
||||
SysPacketsOut: sysPackets,
|
||||
SysPacketsDropped: sysDroppedPackets,
|
||||
MemoryLoad: memoryLoad,
|
||||
}
|
||||
|
||||
// update stats
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/florianl/go-tc"
|
||||
"github.com/mackerelio/go-osstat/cpu"
|
||||
"github.com/mackerelio/go-osstat/memory"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -36,6 +37,16 @@ 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 {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/mackerelio/go-osstat/cpu"
|
||||
"github.com/mackerelio/go-osstat/memory"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -34,6 +35,16 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user