예제 #1
0
파일: module.go 프로젝트: mrkschan/beats
func (msw *metricSetWrapper) multiEventFetch(fetcher mb.EventsFetcher) ([]common.MapStr, error) {
	start := time.Now()
	events, err := fetcher.Fetch()
	elapsed := time.Since(start)

	var rtnEvents []common.MapStr
	if err == nil {
		msw.stats.Add(successesKey, 1)

		for _, event := range events {
			event, err = createEvent(msw, event, nil, start, elapsed)
			if err != nil {
				return nil, errors.Wrap(err, "createEvent failed")
			}
			rtnEvents = append(rtnEvents, event)
		}
	} else {
		msw.stats.Add(failuresKey, 1)

		event, err := createEvent(msw, nil, err, start, elapsed)
		if err != nil {
			return nil, errors.Wrap(err, "createEvent failed")
		}
		rtnEvents = append(rtnEvents, event)
	}

	return rtnEvents, nil
}
예제 #2
0
파일: module.go 프로젝트: yan2jared/beats
func (msw *metricSetWrapper) multiEventFetch(fetcher mb.EventsFetcher, host string) error {
	start := time.Now()
	events, err := fetcher.Fetch(host)
	elapsed := time.Since(start)
	if err == nil {
		msw.stats.Add(successesKey, 1)

		for _, event := range events {
			event, err = createEvent(msw, host, event, nil, start, elapsed)
			if err != nil {
				logp.Warn("createEvent error: %v", err)
			}

			if event != nil {
				msw.module.pubClient.PublishEvent(event)
				msw.stats.Add(eventsKey, 1)
			}
		}
	} else {
		msw.stats.Add(failuresKey, 1)

		event, err := createEvent(msw, host, nil, err, start, elapsed)
		if err != nil {
			logp.Warn("createEvent error: %v", err)
		}

		if event != nil {
			msw.module.pubClient.PublishEvent(event)
			msw.stats.Add(eventsKey, 1)
		}
	}

	return nil
}
예제 #3
0
func WriteEvents(f mb.EventsFetcher, t *testing.T) error {

	if !*dataFlag {
		t.Skip("Skip data generation tests")
	}
	events, err := f.Fetch()
	if err != nil {
		return err
	}

	return createEvent(events[0], f)
}