Files
livekit/pkg/telemetry/prometheus/node_linux.go
David Colburn faa870de3d Move callbacks out of messageRouter (#269)
* move callbacks out of messageRouter

* OCD

* more OCD

* fix forwarder test

* even more OCD

* maximum OCD

* package name collision, copy lock by value
2021-12-17 13:19:23 -08:00

29 lines
630 B
Go

//go:build linux
// +build linux
package prometheus
import (
linuxproc "github.com/c9s/goprocinfo/linux"
"github.com/livekit/protocol/livekit"
)
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
}