Skip to content

Commit e74df72

Browse files
authored
fix panic when monitor starts too quickly (#260)
1 parent 8224e7f commit e74df72

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/stats/monitor.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ func NewMonitor(conf *config.Config) (*Monitor, error) {
8686
maxUtilization: conf.MaxCpuUtilization,
8787
}
8888
cpu, err := hwstats.NewCPUStats(func(idle float64) {
89-
m.cpuLoad.Set(1 - idle/m.cpu.NumCPU())
89+
if m.cpu != nil {
90+
m.cpuLoad.Set(1 - idle/m.cpu.NumCPU())
91+
}
9092
})
9193
if err != nil {
9294
return nil, err

0 commit comments

Comments
 (0)