forked from claranet/rubrik-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (44 loc) · 1.55 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
//
// rubrik-exporter
//
// Exports metrics from rubrik backup for prometheus
//
// License: Apache License Version 2.0,
// Organization: Claranet GmbH
// Author: Martin Weber <[email protected]>
//
package main
import (
"flag"
"net/http"
"github.com/claranet/rubrik-exporter/rubrik"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/log"
)
var rubrikAPI *rubrik.Rubrik
var vmIDNameMap map[string]string
var (
namespace = "rubrik"
rubrikURL = flag.String("rubrik.url", "", "Rubrik URL to connect https://rubrik.local.host")
rubrikUser = flag.String("rubrik.username", "", "Rubrik API User")
rubrikPassword = flag.String("rubrik.password", "", "Rubrik API User Password")
listenAddress = flag.String("listen-address", ":9477", "The address to lisiten on for HTTP requests.")
)
func main() {
flag.Parse()
log.Debug("Create Rubrik Exporter instance")
rubrikAPI = rubrik.NewRubrik(*rubrikURL, *rubrikUser, *rubrikPassword)
prometheus.MustRegister(NewRubrikStatsExport())
prometheus.MustRegister(NewVMStatsExport())
prometheus.MustRegister(NewArchiveLocation())
prometheus.MustRegister(NewManagedVolume())
http.Handle("/metrics", prometheus.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html><head><title>Rubrik Exporter</title></head><body><h1>Rubrik Exporter</h1><p><a href="/metrics">Metrics</a></p></body></html>`))
})
log.Debugf("Starting Server: %s", *listenAddress)
err := http.ListenAndServe(*listenAddress, nil)
if err != nil {
log.Fatal(err)
}
}