示例#1
0
文件: graphite.go 项目: vadv/ostent
func graphiteCommandLine(cli *flag.FlagSet) CommandLineHandler {
	gr := &graphite{
		logger:      NewLogger("[ostent sendto-graphite] "),
		RefreshFlag: flags.Period{Duration: 10 * time.Second}, // 10s default
		ServerAddr:  flags.NewBind(2003),
	}
	cli.Var(&gr.RefreshFlag, "graphite-refresh", "Graphite refresh interval")
	cli.Var(&gr.ServerAddr, "sendto-graphite", "Graphite server address")
	return func() (AtexitHandler, bool, error) {
		if gr.ServerAddr.Host == "" {
			return nil, false, nil
		}
		ostent.AddBackground(func(defaultPeriod flags.Period) {
			/* if gr.RefreshFlag.Duration == 0 { // if .RefreshFlag had no default
				gr.RefreshFlag = defaultPeriod
			} */
			gc := &carbond{
				logger:      gr.logger,
				serveraddr:  gr.ServerAddr.String(),
				PeriodParam: params.NewPeriodParam(gr.RefreshFlag, "refreshgraphite", nil),
			}
			ostent.Register <- gc
		})
		return nil, false, nil
	}
}
示例#2
0
文件: webserver.go 项目: vadv/ostent
func NewWebserver(defport int) *webserver {
	return &webserver{
		logger: NewLogger(fmt.Sprintf("[%d][ostent webserver] ", os.Getpid()), func(l *Logger) {
			l.Flag |= log.Lmicroseconds
		}),
		Bind: flags.NewBind(defport),
	}
}