Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
add simple tool to test how MT aggregates data
Browse files Browse the repository at this point in the history
  • Loading branch information
Dieterbe committed Mar 9, 2017
1 parent ed643f3 commit 589b6cd
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions aggcarbon/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"flag"
"sync"

"fmt"
"net"
"os"
"time"
)

var (
addr string
wg sync.WaitGroup
)

func init() {
flag.StringVar(&addr, "addr", "localhost:2003", "address of carbon host")
}

func main() {
flag.Parse()
conn, err := net.Dial("tcp", addr)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
to := time.Now().Unix()
from := to - 6*24*60*60

wg.Add(8)
go do("fakemetrics.raw.min", conn, from, to)
go do("fakemetrics.raw.max", conn, from, to)
go do("fakemetrics.raw.all", conn, from, to)
go do("fakemetrics.raw.default", conn, from, to)
go do("fakemetrics.agg.min", conn, from, to)
go do("fakemetrics.agg.max", conn, from, to)
go do("fakemetrics.agg.all", conn, from, to)
go do("fakemetrics.agg.default", conn, from, to)
wg.Wait()
}

func do(key string, conn net.Conn, from, to int64) {
i := 0
for ts := from; ts < to; ts++ {
if ts%7200 == 0 {
fmt.Println(key, ts-from, "/", to-from)
}
_, err := fmt.Fprintf(conn, "%s %d %d\n", key, i, ts)
if err != nil {
fmt.Println(err)
}
i++
}
wg.Done()
}

0 comments on commit 589b6cd

Please sign in to comment.