-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
29 lines (24 loc) · 943 Bytes
/
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
package main
import (
"flag"
"github.com/prometheus/client_golang/prometheus"
"metrics-exporter/src"
"metrics-exporter/src/minecraft"
"metrics-exporter/src/thread"
)
func main() {
var port = flag.String("p", "8462", "Service port")
var interval = flag.Int("interval", 30, "Every how many seconds the service will collect metrics from the minecraft server")
var serverAddress = flag.String("mcAddress", "127.0.0.1", "The minecraft server address (just ip/dns)")
var serverPort = flag.Uint("mcPort", 25565, "The minecraft server port")
flag.Parse()
if *serverPort < 0 || *serverPort > 65536 {
panic("Invalid minecraft server port!")
}
promReg := prometheus.NewRegistry()
minecraftListenerPool := thread.NewPool(1)
minecraftListener := minecraft.NewMCMetricsListener(*interval, *serverAddress, *serverPort, promReg)
go minecraftListenerPool.Start(minecraftListener)
server := src.NewServer(promReg)
server.Start(*port)
}