forked from ChristianKniep/statsdaemon
/
main.go
90 lines (83 loc) · 1.82 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"os"
"github.com/codegangsta/cli"
"github.com/zpatrick/go-config"
"github.com/ChristianKniep/statsdaemon/lib"
)
const (
VERSION = "0.8.0"
)
func Run(ctx *cli.Context) {
cfg := config.NewYAMLFile(ctx.String("config"))
sd := statsdaemon.NewStatsdaemon(cfg)
sd.Run()
}
func main() {
app := cli.NewApp()
app.Name = "Port of Etsy's statsd, written in Go (originally based amir/gographite."
app.Usage = "statsdaemon [options]"
app.Version = VERSION
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "address",
Value: ":8125",
Usage: "UDP service address",
},
cli.StringFlag{
Name: "tcpaddr",
Value: "",
Usage: "TCP service address",
},
cli.IntFlag{
Name: "max-udp-packet-size",
Value: 1472,
Usage: "Maximum UDP packet size",
},
cli.StringFlag{
Name: "graphite",
Value: "127.0.0.1:2003",
Usage: "Graphite service address (or - to disable)",
},
cli.IntFlag{
Name: "flush-interval",
Value: 10,
Usage: "Flush interval (seconds)",
},
cli.BoolFlag{
Name: "debug",
Usage: "print statistics sent to graphite",
},
cli.BoolFlag{
Name: "resent-gauges",
Usage: "do sent values to graphite for inactive gauges, as opposed to not sending the previous value",
},
cli.IntFlag{
Name: "persist-count-keys",
Value: 60,
Usage: "number of flush-intervals to persist count keys",
},
cli.StringFlag{
Name: "receive-counter",
Value: "",
Usage: "Metric name for total metrics received per interval",
},
cli.StringFlag{
Name: "prefix",
Value: "",
Usage: "Prefix for all stats",
},
cli.StringFlag{
Name: "postfix",
Value: "",
Usage: "Postfix for all stats",
},
cli.StringFlag{
Name: "percentiles",
Value: "",
Usage: "Comma separated list of percentiles",
},
}
app.Action = Run
app.Run(os.Args)
}