func (p *ProcessStatSample) collectCPUPercent(proc *process.Process) { defer func() { if e := recover(); e != nil { log.Warnf("Recovered from panic on CPU Percent collection. Maybe unsupported on this platform.") } }() // Use 0 interval to get difference since the last call cpuPercent, err := proc.CPUPercent(0 * time.Second) if err != nil { log.Warnf("Error encountered collecting CPU percent: %s", err) } else { p.CPUPercent += cpuPercent } }