// Fetch fetches CPU metrics from the OS. func (m *MetricSet) Fetch(host string) (common.MapStr, error) { cpuStat, err := system.GetCpuTimes() if err != nil { return nil, errors.Wrap(err, "cpu times") } return system.GetCpuStatEvent(cpuStat), nil }
func (m *MetricSeter) Fetch(ms *helper.MetricSet, host string) (event common.MapStr, err error) { cpuStat, err := system.GetCpuTimes() if err != nil { logp.Warn("Getting cpu times: %v", err) return nil, err } event = system.GetCpuStatEvent(cpuStat) return event, nil }
// Fetch fetches CPU metrics from the OS. func (m *MetricSet) Fetch() (common.MapStr, error) { cpuStat, err := system.GetCpuTimes() if err != nil { return nil, errors.Wrap(err, "cpu times") } m.cpu.AddCpuPercentage(cpuStat) loadStat, err := system.GetSystemLoad() if err != nil { return nil, errors.Wrap(err, "load statistics") } event := system.GetCpuStatEvent(cpuStat) event["load"] = loadStat return event, nil }
// Fetch fetches CPU core metrics from the OS. func (m *MetricSet) Fetch() ([]common.MapStr, error) { cpuCoreStat, err := system.GetCpuTimesList() if err != nil { return nil, errors.Wrap(err, "cpu core times") } m.cpu.AddCpuPercentageList(cpuCoreStat) cores := []common.MapStr{} for core, stat := range cpuCoreStat { coreStat := system.GetCpuStatEvent(&stat) coreStat["core"] = core cores = append(cores, coreStat) } return cores, nil }