mirror of
https://github.com/livekit/livekit.git
synced 2026-03-31 02:25:39 +00:00
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.
33 lines
548 B
Go
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
|
|
}
|