-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
46 lines (39 loc) · 1.83 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
// Copyright (C) 2019 by the authors in the project README.md
// See the full license in the project LICENSE file.
package main
import (
"log"
"net/http"
"github.com/man-group/prometheus-flashblade-exporter/collector"
"github.com/man-group/prometheus-flashblade-exporter/fb"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
var (
flashbladeFlag = kingpin.Arg("flashblade", "Address of the target Flashblade.").Required().String()
portFlag = kingpin.Flag("port", "Port to listen on.").Short('p').Default("9130").String()
fsMetricFlag = kingpin.Flag("filesystem-metrics", "Export filesystem and usage data metrics for each user and group.").Default("false").Bool()
fsFilterFlag = kingpin.Flag("filesystem-filter-regexp", "Regexp limiting the filesystems for which metrics are exported").Default(".*").String()
insecureFlag = kingpin.Flag("insecure", "Disable the verification of the SSL certificate").Default("false").Bool()
apiVersionFlag = kingpin.Flag("api-version", "API version to query the flashblade").Default("1.8").String()
)
func init() {
prometheus.MustRegister(version.NewCollector("flashblade_collector"))
}
func listen() {
http.Handle("/metrics", prometheus.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/metrics", http.StatusMovedPermanently)
})
log.Printf("Starting metrics gathering for FlashBlade %v on port %v", *flashbladeFlag, *portFlag)
log.Fatal(http.ListenAndServe(":"+string(*portFlag), nil))
}
func main() {
kingpin.Version("0.5.0")
kingpin.Parse()
fbClient := fb.NewFlashbladeClient(*flashbladeFlag, *insecureFlag, *apiVersionFlag)
fbCollector := collector.NewFlashbladeCollector(fbClient, *fsMetricFlag, *fsFilterFlag)
prometheus.MustRegister(fbCollector)
listen()
}