예제 #1
0
파일: probe.go 프로젝트: tamtam-im/waves
func NewDockerProbe(
	endpoint string,
	dropper report.Reporter,
	annotator report.Reporter,
) (res *Probe) {
	res = &Probe{
		endpoint:   endpoint,
		mu:         &sync.Mutex{},
		containers: map[string]*Container{},
		dropper:    report.NewMetaReporter([]string{"container"}, dropper),
		annotator: report.NewMetaReporter([]string{"docker", "container"},
			annotator),
	}
	return
}
예제 #2
0
func newContainer(
	c *dockercli.Container,
	endpoint string,
	dropper report.Reporter,
	annotator report.Reporter,
) (res *Container) {
	res = &Container{
		id:        c.ID,
		name:      strings.TrimPrefix(c.Name, "/"),
		endpoint:  endpoint,
		statMutex: &sync.Mutex{},
		annotator: annotator,
	}

	// Check for "WAVES_IGNORE" env
	env := dockercli.Env(c.Config.Env)
	if env.Get("WAVES_WATCH") != "" {
		res.watch = true
		escaped := res.formatName(c.Name)
		res.dropper = report.NewMetaReporter([]string{escaped}, dropper)
	} else {
		logx.Infof("using dummy mode for %s", res.name)
	}
	return
}
예제 #3
0
파일: wavesd.go 프로젝트: tamtam-im/waves
func main() {
	flags.New().SetPrefix("WAVES").Boot()
	logx.SetLevel(log_level)

	ctx, cancel := context.WithCancel(context.Background())

	mach := machine.NewMachine(ctx, interval)
	go mach.Start()

	datapointReporter := datapoint.NewReporter(&datapointOptions, noop)

	u, err := url.Parse(annotationsEndpoint)
	logx.OnFatal(err)
	if token != "" {
		u.User = url.User(token)
	}
	annReporter := annotation.NewReporter(&annotation.ReporterOptions{u}, noop)

	dp := dockerprobe.NewDockerProbe(dockerEndpoint,
		makeDockerReporter(datapointReporter),
		report.NewMetaReporter(strings.Split(dockerAnnotationTags, ","),
			annReporter),
	)
	err = mach.Add(dp)
	logx.OnFatal(err)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)
	<-sigChan
	logx.Info("bye")
	cancel()
}
예제 #4
0
func (c *Container) Emit(when time.Time, what string) {
	a := report.NewMetaReporter([]string{what}, c.annotator)
	go a.Drop(report.NewReport(c.name, what, when))
}
예제 #5
0
파일: wavesd.go 프로젝트: tamtam-im/waves
func makeDockerReporter(reporter report.Reporter) report.Reporter {
	return report.NewMetaReporter(
		[]string{dockerDPPrefix},
		report.NewMetaReporter([]string{token}, reporter))
}