From 1229dafcd69d7c397e02c7f53f9a0ae92fbe4744 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Thu, 14 Dec 2023 11:10:20 -0800 Subject: [PATCH] fix panic (#562) --- pkg/service/service_prom.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/service/service_prom.go b/pkg/service/service_prom.go index 243059de..8b9899b0 100644 --- a/pkg/service/service_prom.go +++ b/pkg/service/service_prom.go @@ -76,9 +76,13 @@ func (s *Service) promProcUpdate(pUsage map[int]float64) map[string]float64 { eUsage := make(map[string]float64) for _, h := range s.activeHandlers { - if usage, ok := pUsage[h.cmd.Process.Pid]; ok { - eUsage[h.req.EgressId] = usage - h.updateCPU(usage) + if cmd := h.cmd; cmd != nil { + if process := cmd.Process; process != nil { + if usage, ok := pUsage[process.Pid]; ok { + eUsage[h.req.EgressId] = usage + h.updateCPU(usage) + } + } } }