get system stats from /proc only on linux (#96)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// +build linux
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
linuxproc "github.com/c9s/goprocinfo/linux"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
)
|
||||
|
||||
func updateCurrentNodeSystemStats(nodeStats *livekit.NodeStats) error {
|
||||
cpuInfo, err := linuxproc.ReadCPUInfo("/proc/cpuinfo")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
loadAvg, err := linuxproc.ReadLoadAvg("/proc/loadavg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nodeStats.NumCpus = uint32(cpuInfo.NumCPU())
|
||||
nodeStats.LoadAvgLast1Min = float32(loadAvg.Last1Min)
|
||||
nodeStats.LoadAvgLast5Min = float32(loadAvg.Last5Min)
|
||||
nodeStats.LoadAvgLast15Min = float32(loadAvg.Last15Min)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// +build !linux
|
||||
|
||||
package stats
|
||||
|
||||
import livekit "github.com/livekit/protocol/proto"
|
||||
|
||||
func updateCurrentNodeSystemStats(nodeStats *livekit.NodeStats) error {
|
||||
return nil
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
linuxproc "github.com/c9s/goprocinfo/linux"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/rtcp"
|
||||
@@ -96,22 +95,3 @@ func UpdateCurrentNodeStats(nodeStats *livekit.NodeStats) error {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func updateCurrentNodeSystemStats(nodeStats *livekit.NodeStats) error {
|
||||
cpuInfo, err := linuxproc.ReadCPUInfo("/proc/cpuinfo")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
loadAvg, err := linuxproc.ReadLoadAvg("/proc/loadavg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nodeStats.NumCpus = uint32(cpuInfo.NumCPU())
|
||||
nodeStats.LoadAvgLast1Min = float32(loadAvg.Last1Min)
|
||||
nodeStats.LoadAvgLast5Min = float32(loadAvg.Last5Min)
|
||||
nodeStats.LoadAvgLast15Min = float32(loadAvg.Last15Min)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user