Files
livekit/pkg/telemetry/prometheus/node_linux.go
David Zhao 956735ae05 Fix node stats updates on Windows (#1748)
Because we aren't able to get CPU count/load info on Windows, they are
stubbed out to return placeholders. This restores compatibility to run
on Windows.
2023-05-29 10:53:08 -07:00

33 lines
548 B
Go

//go:build linux
// +build linux
package prometheus
import (
"fmt"
"github.com/florianl/go-tc"
)
func getTCStats() (packets, drops uint32, err error) {
rtnl, err := tc.Open(&tc.Config{})
if err != nil {
err = fmt.Errorf("could not open rtnetlink socket: %v", err)
return
}
defer rtnl.Close()
qdiscs, err := rtnl.Qdisc().Get()
if err != nil {
err = fmt.Errorf("could not get qdiscs: %v", err)
return
}
for _, qdisc := range qdiscs {
packets = packets + qdisc.Stats.Packets
drops = drops + qdisc.Stats.Drops
}
return
}