forked from claranet/rubrik-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_archive.go
62 lines (49 loc) · 1.32 KB
/
export_archive.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
//
// 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 (
"github.com/claranet/rubrik-exporter/rubrik"
"github.com/prometheus/client_golang/prometheus"
)
// ArchiveLocation ...
type ArchiveLocation struct {
ArchiveLocationStatus *prometheus.GaugeVec
}
// Describe ...
func (e ArchiveLocation) Describe(ch chan<- *prometheus.Desc) {
e.ArchiveLocationStatus.Describe(ch)
}
// Collect ...
func (e *ArchiveLocation) Collect(ch chan<- prometheus.Metric) {
storages := make(map[string]rubrik.VmStorage)
for _, s := range rubrikAPI.GetPerVMStorage() {
storages[s.ID] = s
}
locations := rubrikAPI.GetArchiveLocations()
for _, l := range locations {
var g prometheus.Gauge
g = e.ArchiveLocationStatus.WithLabelValues(l.Name, l.Bucket, l.IPAddress)
if l.IsActive {
g.Set(1)
} else {
g.Set(0)
}
g.Collect(ch)
}
}
// NewArchiveLocation ...
func NewArchiveLocation() *ArchiveLocation {
return &ArchiveLocation{
ArchiveLocationStatus: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace, Name: "archive_location_status",
Help: "Archive Loction Status - 1: Active, 0: Inactive",
}, []string{"name", "bucket", "target"}),
}
}