Beispiel #1
0
// 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
}
Beispiel #2
0
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
}