@@ -23,7 +23,7 @@ require (
|
|||||||
github.com/jxskiss/base62 v1.1.0
|
github.com/jxskiss/base62 v1.1.0
|
||||||
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
|
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20250310153736-45596af895b6
|
github.com/livekit/mediatransportutil v0.0.0-20250310153736-45596af895b6
|
||||||
github.com/livekit/protocol v1.36.2-0.20250404201741-33d360bf92c1
|
github.com/livekit/protocol v1.36.2-0.20250405060655-61cc1f628d6a
|
||||||
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126
|
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126
|
||||||
github.com/mackerelio/go-osstat v0.2.5
|
github.com/mackerelio/go-osstat v0.2.5
|
||||||
github.com/magefile/mage v1.15.0
|
github.com/magefile/mage v1.15.0
|
||||||
|
|||||||
@@ -171,8 +171,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
|
|||||||
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20250310153736-45596af895b6 h1:6ZhtnY9I9knfm3ieIPpznQSEU2rDECO8yliW/ANLQ7U=
|
github.com/livekit/mediatransportutil v0.0.0-20250310153736-45596af895b6 h1:6ZhtnY9I9knfm3ieIPpznQSEU2rDECO8yliW/ANLQ7U=
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20250310153736-45596af895b6/go.mod h1:36s+wwmU3O40IAhE+MjBWP3W71QRiEE9SfooSBvtBqY=
|
github.com/livekit/mediatransportutil v0.0.0-20250310153736-45596af895b6/go.mod h1:36s+wwmU3O40IAhE+MjBWP3W71QRiEE9SfooSBvtBqY=
|
||||||
github.com/livekit/protocol v1.36.2-0.20250404201741-33d360bf92c1 h1:vI4PrnWsVBWJ/PXw++QLR/7tmO3UweirJRy512KskQw=
|
github.com/livekit/protocol v1.36.2-0.20250405060655-61cc1f628d6a h1:HcEdNqqoZc60yfwHFPVURPjZT91FbX6+gMSifdCEizQ=
|
||||||
github.com/livekit/protocol v1.36.2-0.20250404201741-33d360bf92c1/go.mod h1:WrT/CYRxtMNOVUjnIPm5OjWtEkmreffTeE1PRZwlRg4=
|
github.com/livekit/protocol v1.36.2-0.20250405060655-61cc1f628d6a/go.mod h1:WrT/CYRxtMNOVUjnIPm5OjWtEkmreffTeE1PRZwlRg4=
|
||||||
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126 h1:fzuYpAQbCid7ySPpQWWePfQOWUrs8x6dJ0T3Wl07n+Y=
|
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126 h1:fzuYpAQbCid7ySPpQWWePfQOWUrs8x6dJ0T3Wl07n+Y=
|
||||||
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126/go.mod h1:X5WtEZ7OnEs72Fi5/J+i0on3964F1aynQpCalcgMqRo=
|
github.com/livekit/psrpc v0.6.1-0.20250205181828-a0beed2e4126/go.mod h1:X5WtEZ7OnEs72Fi5/J+i0on3964F1aynQpCalcgMqRo=
|
||||||
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
|
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package prometheus
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mackerelio/go-osstat/memory"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
|
||||||
@@ -43,7 +42,8 @@ var (
|
|||||||
promSysPacketGauge *prometheus.GaugeVec
|
promSysPacketGauge *prometheus.GaugeVec
|
||||||
promSysDroppedPacketPctGauge prometheus.Gauge
|
promSysDroppedPacketPctGauge prometheus.Gauge
|
||||||
|
|
||||||
cpuStats *hwstats.CPUStats
|
cpuStats *hwstats.CPUStats
|
||||||
|
memoryStats *hwstats.MemoryStats
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(nodeID string, nodeType livekit.NodeType) error {
|
func Init(nodeID string, nodeType livekit.NodeType) error {
|
||||||
@@ -122,6 +122,11 @@ func Init(nodeID string, nodeType livekit.NodeType) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memoryStats, err = hwstats.NewMemoryStats()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,21 +136,9 @@ func GetNodeStats(nodeStartedAt int64, prevStats []*livekit.NodeStats, rateInter
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var cpuLoad float64
|
|
||||||
cpuIdle := cpuStats.GetCPUIdle()
|
|
||||||
if cpuIdle > 0 {
|
|
||||||
cpuLoad = 1 - (cpuIdle / cpuStats.NumCPU())
|
|
||||||
}
|
|
||||||
|
|
||||||
// On MacOS, get "\"vm_stat\": executable file not found in $PATH" although it is in /usr/bin
|
// 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.
|
// So, do not error out. Use the information if it is available.
|
||||||
memTotal := uint64(0)
|
memUsed, memTotal, _ := memoryStats.GetMemory()
|
||||||
memUsed := uint64(0)
|
|
||||||
memInfo, _ := memory.Get()
|
|
||||||
if memInfo != nil {
|
|
||||||
memTotal = memInfo.Total
|
|
||||||
memUsed = memInfo.Used
|
|
||||||
}
|
|
||||||
|
|
||||||
sysPackets, sysDroppedPackets, _ := getTCStats()
|
sysPackets, sysDroppedPackets, _ := getTCStats()
|
||||||
promSysPacketGauge.WithLabelValues("out").Set(float64(sysPackets - sysPacketsStart))
|
promSysPacketGauge.WithLabelValues("out").Set(float64(sysPackets - sysPacketsStart))
|
||||||
@@ -175,7 +168,7 @@ func GetNodeStats(nodeStartedAt int64, prevStats []*livekit.NodeStats, rateInter
|
|||||||
ForwardLatency: forwardLatency.Load(),
|
ForwardLatency: forwardLatency.Load(),
|
||||||
ForwardJitter: forwardJitter.Load(),
|
ForwardJitter: forwardJitter.Load(),
|
||||||
NumCpus: uint32(cpuStats.NumCPU()), // this will round down to the nearest integer
|
NumCpus: uint32(cpuStats.NumCPU()), // this will round down to the nearest integer
|
||||||
CpuLoad: float32(cpuLoad),
|
CpuLoad: float32(cpuStats.GetCPULoad()),
|
||||||
MemoryTotal: memTotal,
|
MemoryTotal: memTotal,
|
||||||
MemoryUsed: memUsed,
|
MemoryUsed: memUsed,
|
||||||
LoadAvgLast1Min: float32(loadAvg.Loadavg1),
|
LoadAvgLast1Min: float32(loadAvg.Loadavg1),
|
||||||
|
|||||||
Reference in New Issue
Block a user