Skip to content

Commit 0dbc928

Browse files
committed
Update filesystem perf functions to mimic array perf functions to add support for SMB
1 parent 581948a commit 0dbc928

File tree

2 files changed

+84
-92
lines changed

2 files changed

+84
-92
lines changed

internal/openmetrics-exporter/file_systems_perf_collector.go

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -23,78 +23,81 @@ func (c *FileSystemsPerfCollector) Describe(ch chan<- *prometheus.Desc) {
2323
}
2424

2525
func (c *FileSystemsPerfCollector) Collect(ch chan<- prometheus.Metric) {
26-
filesystemsperf := c.Client.GetFileSystemsPerformance(c.FileSystems, "NFS")
27-
if len(filesystemsperf.Items) == 0 {
26+
if len(c.FileSystems.Items) == 0 {
2827
return
2928
}
3029

31-
for _, fp := range filesystemsperf.Items {
32-
ch <- prometheus.MustNewConstMetric(
33-
c.LatencyDesc,
34-
prometheus.GaugeValue,
35-
fp.UsecPerOtherOp,
36-
fp.Name, "usec_per_other_op",
37-
)
38-
ch <- prometheus.MustNewConstMetric(
39-
c.LatencyDesc,
40-
prometheus.GaugeValue,
41-
fp.UsecPerReadOp,
42-
fp.Name, "usec_per_read_op",
43-
)
44-
ch <- prometheus.MustNewConstMetric(
45-
c.LatencyDesc,
46-
prometheus.GaugeValue,
47-
fp.UsecPerWriteOp,
48-
fp.Name, "usec_per_write_op",
49-
)
50-
ch <- prometheus.MustNewConstMetric(
51-
c.ThroughputDesc,
52-
prometheus.GaugeValue,
53-
fp.OthersPerSec,
54-
fp.Name, "others_per_sec",
55-
)
56-
ch <- prometheus.MustNewConstMetric(
57-
c.ThroughputDesc,
58-
prometheus.GaugeValue,
59-
fp.ReadsPerSec,
60-
fp.Name, "reads_per_sec",
61-
)
62-
ch <- prometheus.MustNewConstMetric(
63-
c.ThroughputDesc,
64-
prometheus.GaugeValue,
65-
fp.WritesPerSec,
66-
fp.Name, "writes_per_sec",
67-
)
68-
ch <- prometheus.MustNewConstMetric(
69-
c.BandwidthDesc,
70-
prometheus.GaugeValue,
71-
fp.ReadBytesPerSec,
72-
fp.Name, "read_bytes_per_sec",
73-
)
74-
ch <- prometheus.MustNewConstMetric(
75-
c.BandwidthDesc,
76-
prometheus.GaugeValue,
77-
fp.WriteBytesPerSec,
78-
fp.Name, "write_bytes_per_sec",
79-
)
80-
ch <- prometheus.MustNewConstMetric(
81-
c.AverageSizeDesc,
82-
prometheus.GaugeValue,
83-
fp.BytesPerOp,
84-
fp.Name, "bytes_per_op",
85-
)
86-
ch <- prometheus.MustNewConstMetric(
87-
c.AverageSizeDesc,
88-
prometheus.GaugeValue,
89-
fp.BytesPerRead,
90-
fp.Name, "bytes_per_read",
91-
)
92-
ch <- prometheus.MustNewConstMetric(
93-
c.AverageSizeDesc,
94-
prometheus.GaugeValue,
95-
fp.BytesPerWrite,
96-
fp.Name, "bytes_per_write",
97-
)
30+
protocols := []string{"all", "SMB", "NFS"}
31+
for _, proto := range protocols {
32+
filesystemsperf := c.Client.GetFileSystemsPerformance(c.FileSystems, proto)
33+
for _, fp := range filesystemsperf.Items {
34+
ch <- prometheus.MustNewConstMetric(
35+
c.LatencyDesc,
36+
prometheus.GaugeValue,
37+
fp.UsecPerOtherOp,
38+
fp.Name, "usec_per_other_op", proto,
39+
)
40+
ch <- prometheus.MustNewConstMetric(
41+
c.LatencyDesc,
42+
prometheus.GaugeValue,
43+
fp.UsecPerReadOp,
44+
fp.Name, "usec_per_read_op", proto,
45+
)
46+
ch <- prometheus.MustNewConstMetric(
47+
c.LatencyDesc,
48+
prometheus.GaugeValue,
49+
fp.UsecPerWriteOp,
50+
fp.Name, "usec_per_write_op", proto,
51+
)
52+
ch <- prometheus.MustNewConstMetric(
53+
c.ThroughputDesc,
54+
prometheus.GaugeValue,
55+
fp.OthersPerSec,
56+
fp.Name, "others_per_sec", proto,
57+
)
58+
ch <- prometheus.MustNewConstMetric(
59+
c.ThroughputDesc,
60+
prometheus.GaugeValue,
61+
fp.ReadsPerSec,
62+
fp.Name, "reads_per_sec", proto,
63+
)
64+
ch <- prometheus.MustNewConstMetric(
65+
c.ThroughputDesc,
66+
prometheus.GaugeValue,
67+
fp.WritesPerSec,
68+
fp.Name, "writes_per_sec", proto,
69+
)
70+
ch <- prometheus.MustNewConstMetric(
71+
c.BandwidthDesc,
72+
prometheus.GaugeValue,
73+
fp.ReadBytesPerSec,
74+
fp.Name, "read_bytes_per_sec", proto,
75+
)
76+
ch <- prometheus.MustNewConstMetric(
77+
c.BandwidthDesc,
78+
prometheus.GaugeValue,
79+
fp.WriteBytesPerSec,
80+
fp.Name, "write_bytes_per_sec", proto,
81+
)
82+
ch <- prometheus.MustNewConstMetric(
83+
c.AverageSizeDesc,
84+
prometheus.GaugeValue,
85+
fp.BytesPerOp,
86+
fp.Name, "bytes_per_op", proto,
87+
)
88+
ch <- prometheus.MustNewConstMetric(
89+
c.AverageSizeDesc,
90+
prometheus.GaugeValue,
91+
fp.BytesPerRead,
92+
fp.Name, "bytes_per_read", proto,
93+
)
94+
ch <- prometheus.MustNewConstMetric(
95+
c.AverageSizeDesc,
96+
prometheus.GaugeValue,
97+
fp.BytesPerWrite,
98+
fp.Name, "bytes_per_write", proto,
99+
)
100+
}
98101
}
99102
}
100103

@@ -104,25 +107,25 @@ func NewFileSystemsPerfCollector(fb *client.FBClient,
104107
LatencyDesc: prometheus.NewDesc(
105108
"purefb_file_systems_performance_latency_usec",
106109
"FlashBlade file systems latency",
107-
[]string{"name", "dimension"},
110+
[]string{"name", "dimension", "protocol"},
108111
prometheus.Labels{},
109112
),
110113
ThroughputDesc: prometheus.NewDesc(
111114
"purefb_file_systems_performance_throughput_iops",
112115
"FlashBlade file systems throughput",
113-
[]string{"name", "dimension"},
116+
[]string{"name", "dimension", "protocol"},
114117
prometheus.Labels{},
115118
),
116119
BandwidthDesc: prometheus.NewDesc(
117120
"purefb_file_systems_performance_bandwidth_bytes",
118121
"FlashBlade file systems bandwidth",
119-
[]string{"name", "dimension"},
122+
[]string{"name", "dimension", "protocol"},
120123
prometheus.Labels{},
121124
),
122125
AverageSizeDesc: prometheus.NewDesc(
123126
"purefb_file_systems_performance_average_bytes",
124127
"FlashBlade file systems average operations size",
125-
[]string{"name", "dimension"},
128+
[]string{"name", "dimension", "protocol"},
126129
prometheus.Labels{},
127130
),
128131
Client: fb,

internal/rest-client/filesystems_perf.go

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,16 @@ func (fb *FBClient) GetFileSystemsPerformance(f *FileSystemsList,
1313
result := new(FileSystemsPerformanceList)
1414
switch protocol {
1515
case "all", "NFS", "SMB":
16-
temp := new(FileSystemsPerformanceList)
17-
for i := 0; i < len(f.Items); i += 5 {
18-
n := ""
19-
for j := 0; (j < 5) && (i+j < len(f.Items)); j++ {
20-
n = n + f.Items[i+j].Name + ","
21-
}
22-
n = n[:len(n)-1]
23-
res, _ := fb.RestClient.R().
24-
SetResult(&temp).
25-
SetQueryParam("names", n).
16+
res, _ := fb.RestClient.R().
17+
SetResult(&result).
18+
SetQueryParam("protocol", protocol).
19+
Get(uri)
20+
if res.StatusCode() == 401 {
21+
fb.RefreshSession()
22+
fb.RestClient.R().
23+
SetResult(&result).
2624
SetQueryParam("protocol", protocol).
2725
Get(uri)
28-
if res.StatusCode() == 401 {
29-
fb.RefreshSession()
30-
fb.RestClient.R().
31-
SetResult(&temp).
32-
SetQueryParam("names", n).
33-
SetQueryParam("protocol", protocol).
34-
Get(uri)
35-
}
36-
result.Items = append(result.Items, temp.Items...)
3726
}
3827
}
3928
return result

0 commit comments

Comments
 (0)