Esempio n. 1
0
func main() {

	config.Init("f", "pandora", "pandora-test.conf")

	var conf Config
	if err := config.Load(&conf); err != nil {
		log.Fatal("config.Load failed:", err)
		return
	}

	svr, err := New(conf)

	router := restrpc.Router{
		Factory:       restrpc.Factory,
		PatternPrefix: "/v4",
		Mux:           restrpc.NewServeMux(),
	}

	err = http.ListenAndServe(conf.Port, router.Register(svr))

	if err != nil {
		log.Fatal(err)
	}

}
Esempio n. 2
0
func New() *Service {

	config.Init("f", "tester", "collect.conf")
	var conf TesterConfig
	if err := config.Load(&conf); err != nil {
		log.Fatal("config.Load failed:", err)
		return nil
	}

	//init mongo
	var colls collection
	_, err := mgoutil.Open(&colls, &mgoutil.Config{Host: "127.0.0.1", DB: "pandora_test"})
	if err != nil {
		log.Fatal("open mongo fail:", err)
	}
	colls.Alert.RemoveAll(M{})
	colls.Repo.RemoveAll(M{})
	colls.RepoConfig.RemoveAll(M{})
	c := NewInfluxClient()

	db, err := bolt.Open("RepoConfigDB", 0600, nil)
	if err != nil {
		log.Fatal("RepoConfigDB open fail", err)
	}

	//init service
	srv := &Service{colls: colls, influxClient: c, done: make(chan bool), db: db}
	return srv
}
Esempio n. 3
0
func main() {

	config.Init("f", "", "benchmark.conf")

	var wg sync.WaitGroup
	var conf Config
	// timer := time.NewTimer(3 * time.Minute)
	if err := config.Load(&conf); err != nil {
		qlog.Fatal("config.Load failed:", err)
		return
	}

	qlog.SetOutputLevel(conf.DebugLevel)
	host, err := url.Parse(conf.URL)
	if err != nil {
		return
	}

	dbUrl := conf.URL + "/query?q=" + url.QueryEscape(fmt.Sprintf("create database %s", conf.Database))
	rpURL := conf.URL + "/query?q=" + url.QueryEscape(fmt.Sprintf("create retention policy %s on %s duration 3d replication 1", conf.URL, conf.Database, conf.Retention))
	http.Get(dbUrl)
	http.Get(rpURL)

	var gorutineClients []*client.Client
	gorutineClients = make([]*client.Client, conf.GorutineNum)

	qlog.Debugf("The gorutineNum is %d", conf.GorutineNum)

	for i := 0; i < conf.GorutineNum; i++ {

		gorutineClients[i], err = client.NewClient(client.Config{URL: *host})
		if err != nil {
			return
		}

		wg.Add(1)
		go writePoints(i, gorutineClients[i], &conf, &wg)
	}
	wg.Wait()

	// <-timer.C
	return
}
Esempio n. 4
0
func main() {

	config.Init("f", "proxy", "proxy.conf")
	var proxy Proxy
	if err := config.Load(&proxy); err != nil {
		log.Fatal("config.Load failed:", err)
		return
	}
	log.SetOutputLevel(proxy.DebugLevel)

	http.HandleFunc("/send/", proxy.sendHandler)
	http.HandleFunc("/static/", proxy.staticHandler)
	http.HandleFunc("/", proxy.handler)
	http.HandleFunc("/test", proxy.testHandler)
	err := http.ListenAndServe(":"+strconv.Itoa(proxy.Port), nil)
	if err != nil {
		log.Error(err)
	}
}
Esempio n. 5
0
func New() *Service {

	config.Init("f", "tester", "collect.conf")
	var conf TesterConfig
	if err := config.Load(&conf); err != nil {
		log.Fatal("config.Load failed:", err)
		return nil
	}

	//init mongo
	var colls collection
	_, err := mgoutil.Open(&colls, &mgoutil.Config{Host: "127.0.0.1", DB: "pandora_test"})
	if err != nil {
		log.Fatal("open mongo fail:", err)
	}
	c := NewInfluxClient()

	//init service
	srv := &Service{colls: colls, influxClient: c, done: make(chan bool)}
	return srv
}