// Fetch fetches memory metrics from the OS. func (m *MetricSet) Fetch(host string) (event common.MapStr, err error) { memStat, err := system.GetMemory() if err != nil { return nil, errors.Wrap(err, "memory") } system.AddMemPercentage(memStat) swapStat, err := system.GetSwap() if err != nil { return nil, errors.Wrap(err, "swap") } system.AddSwapPercentage(swapStat) return common.MapStr{ "mem": system.GetMemoryEvent(memStat), "swap": system.GetSwapEvent(swapStat), }, nil }
func (m *MetricSeter) Fetch(ms *helper.MetricSet, host string) (event common.MapStr, err error) { memStat, err := system.GetMemory() if err != nil { logp.Warn("Getting memory details: %v", err) return nil, err } swapStat, err := system.GetSwap() if err != nil { logp.Warn("Getting swap details: %v", err) return nil, err } event = common.MapStr{ "mem": system.GetMemoryEvent(memStat), "swap": system.GetSwapEvent(swapStat), } return event, nil }