-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFrego.go
99 lines (56 loc) · 1.74 KB
/
Frego.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
88
89
90
91
92
93
94
95
96
97
98
99
//Frego
package Frego
import (
"crypto/x509"
"crypto/tls"
"flag"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
"time"
"github.com/prometheus/client_golang/prometheus"
)
var errorCounter = prometheus.NewCounter(prometheus.CounterOpts {
Namespace: "mesos",
Subsystem: "collector",
Name: "errors_total",
Help: "Total Number of internal mesos-collector errors.",
})
func init() {
}
func mkHttpClient(url string, timeout time.Duration, auth authInfo, certPool *x509.CertPool ) *httpClient {
transport := &http.Transport{
TLSClientConfig: &tls.Config{RootCAs: certPool},
}
var redirectFunc func(req *http.Request, via[]*http.Request) error
if auth.username != "" && auth.password != "" {
//Auth information is only available in the current context -> use lambda
redirectFunc = func(req *http.Request, via[]*http.Request) error {
req.SetBasicAuth(auth.username, auth.password)
return nil
}
}
return &httpClient {
http.Client{Timeout: timeout, Transport: transport, CheckRedirect: redirectFunc},
url,
auth,
}
}
func csvInputToList(input string)[]string {
var entryList []string
if input == "" {
return entryList
}
sanitizedString := strings.Replace(input, "", "", -1)
entryList = strings.Split(sanitizedString, ",")
return entryList
}
func main() {
masterURL := fs.String("master", "", "Expose metrics from master running on this URL")
slaveURL := fs.String("slave", "", "Expose metrics from slave running on this URL")
fs := flag.NewFlagSet("Frego", flag.ExitOnError)
timeout := fs.Duration("timeout", 5*time.Second, "Master polling timeout" )
exportedTaskLabels = fs.String("exportedTaskLabels", "", "Comma separated list of task labels to include the corresponding metric")
}