Пример #1
0
func main() {
	flag.Parse()

	out, err := statstore.GetStorer(*outPath)
	if err != nil {
		log.Fatalf("Error creating storer: %v", err)
	}
	defer out.Close()

	proto := map[string]interface{}{}
	if *protoFile != "" {
		f, err := os.Open(*protoFile)
		if err != nil {
			log.Fatalf("Error opening proto file:  %v", err)
		}
		err = json.NewDecoder(f).Decode(&proto)
		if err != nil {
			log.Fatalf("Error parsing proto: %v", err)
		}
	}

	log.Printf("Capturing %v to %v", *server, *outPath)

	gatherStats(out, proto)
}
Пример #2
0
func main() {
	flag.Parse()

	out, err := statstore.GetStorer(*outPath)
	if err != nil {
		log.Fatalf("Error creating storer: %v", err)
	}
	defer out.Close()

	client := connect()
	if client == nil {
		log.Fatalf("Error making first connection to couch")
	}
	defer client.Close()

	proto := map[string]interface{}{}
	if *protoFile != "" {
		f, err := os.Open(*protoFile)
		if err != nil {
			log.Fatalf("Error opening proto file:  %v", err)
		}
		err = json.NewDecoder(f).Decode(&proto)
		if err != nil {
			log.Fatalf("Error parsing proto: %v", err)
		}
	}

	gatherStats(client, out, proto)
}
Пример #3
0
func main() {
	r, err := statstore.GetStoreReader(os.Args[1])
	maybefatal(err)
	defer r.Close()
	w, err := statstore.GetStorer(os.Args[2])
	maybefatal(err)
	defer w.Close()

	ch := make(chan statstore.StoredItem, 100)

	wg.Add(1)
	go storer(w, ch)

	for {
		m, err := r.Next()
		if err == io.EOF {
			return
		}
		if err != nil {
			log.Printf("Error reading an entry, stopping: %v", err)
			return
		}
		log.Printf("Recording entry from %v", m.Timestamp())
		ch <- m
	}
	close(ch)

	wg.Wait()
}