From 2baea769c7437fc3e3c69590d8298b1e7d42e057 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Mon, 11 Dec 2023 14:40:00 -0800 Subject: [PATCH] Replace old cpu stats --- pkg/stats/monitor.go | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/pkg/stats/monitor.go b/pkg/stats/monitor.go index 7523d017..a3c0dfda 100644 --- a/pkg/stats/monitor.go +++ b/pkg/stats/monitor.go @@ -35,12 +35,10 @@ type Monitor struct { cpuCostConfig config.CPUCostConfig promCPULoad prometheus.Gauge - promCPULoadV2 prometheus.Gauge promProcCPULoad *prometheus.GaugeVec requestGauge *prometheus.GaugeVec - cpuStats *utils.CPUStats - procStats *utils.CPUStats + cpuStats *utils.CPUStats pendingCPUs atomic.Float64 @@ -63,15 +61,8 @@ func (m *Monitor) Start( canAcceptRequest func() float64, procUpdate func(map[int]float64) map[string]float64, ) error { - cpuStats, err := utils.NewCPUStats(func(idle float64) { - m.promCPULoad.Set(1 - idle/m.cpuStats.NumCPU()) - }) - if err != nil { - return err - } - procStats, err := utils.NewProcCPUStats(func(idle float64, usage map[int]float64) { - m.promCPULoadV2.Set(1 - idle/m.cpuStats.NumCPU()) + m.promCPULoad.Set(1 - idle/m.cpuStats.NumCPU()) egressUsage := procUpdate(usage) for egressID, cpuUsage := range egressUsage { m.promProcCPULoad.With(prometheus.Labels{"egress_id": egressID}).Set(cpuUsage) @@ -86,9 +77,7 @@ func (m *Monitor) Start( if err != nil { return err } - - m.cpuStats = cpuStats - m.procStats = procStats + m.cpuStats = procStats if err = m.checkCPUConfig(); err != nil { return err @@ -115,13 +104,6 @@ func (m *Monitor) Start( ConstLabels: prometheus.Labels{"node_id": conf.NodeID, "node_type": "EGRESS", "cluster_id": conf.ClusterID}, }) - m.promCPULoadV2 = prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "livekit", - Subsystem: "node", - Name: "cpu_load_v2", - ConstLabels: prometheus.Labels{"node_id": conf.NodeID, "cluster_id": conf.ClusterID}, - }) - m.promProcCPULoad = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "livekit", Subsystem: "egress", @@ -136,7 +118,7 @@ func (m *Monitor) Start( ConstLabels: prometheus.Labels{"node_id": conf.NodeID, "cluster_id": conf.ClusterID}, }, []string{"type"}) - prometheus.MustRegister(promNodeAvailable, promCanAcceptRequest, m.promCPULoad, m.promCPULoadV2, m.promProcCPULoad, m.requestGauge) + prometheus.MustRegister(promNodeAvailable, promCanAcceptRequest, m.promCPULoad, m.promProcCPULoad, m.requestGauge) return nil }