forked from tchow-stripe/presto_metrico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
59 lines (47 loc) · 1.26 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/ooyala/go-dogstatsd"
"github.com/pborman/getopt"
)
var (
usage = fmt.Sprintf(`
Presto Metrico - Collect and send Presto Metrics to datadog
OPTIONS:
-c
The coordinator node we are going to pull metrics from
-d
The uri for the statsd client. Defaults to 127.0.0.1:8125
-t
The time in secs between sending metrics
`)
commandOptions = getopt.New()
coordinatorOpts = commandOptions.StringLong("coordinator", 'c', "", "Address of the Presto coordinator")
dogstatsdServerOpts = commandOptions.StringLong("dogstatsd", 'd', "127.0.0.1:8125", "Address for the statsd server")
metricsIntervalOpts = commandOptions.IntLong("timer", 't', 15, "Time in seconds to trigger timer to send metrics")
)
func printHelp() {
log.Println(usage)
os.Exit(0)
}
func main() {
if len(os.Args) < 2 {
printHelp()
}
commandOptions.Parse(os.Args)
os.Setenv("PRESTO_COORDINATOR", *coordinatorOpts)
log.Println("Starting Presto Metrico")
client, err := dogstatsd.New(*dogstatsdServerOpts)
if err != nil {
log.Fatal(err)
}
seconds := time.Duration(*metricsIntervalOpts)
t := time.NewTicker(seconds * time.Second)
for now := range t.C {
log.Println("Sending metrics: ", now)
ProcessJMXMetrics(client)
}
}