@@ -83,63 +83,153 @@ func (*mdiskgrpCollector) Describe(ch chan<- *prometheus.Desc) {
83
83
//Collect collects metrics from Spectrum Virtualize Restful API
84
84
func (c * mdiskgrpCollector ) Collect (sClient utils.SpectrumClient , ch chan <- prometheus.Metric ) error {
85
85
86
- log .Debugln ("MDiskgrp collector is starting " )
86
+ log .Debugln ("Entering MDiskgrp collector ... " )
87
87
reqSystemURL := "https://" + sClient .IpAddress + ":7443/rest/lsmdiskgrp"
88
- mDiskGrpRes , err := sClient .CallSpectrumAPI (reqSystemURL )
89
- mDiskGrpArray := gjson .Parse (mDiskGrpRes ).Array ()
88
+ mDiskGrpResp , err := sClient .CallSpectrumAPI (reqSystemURL )
89
+ if err != nil {
90
+ log .Errorf ("Executing lsmdiskgrp cmd failed: %s" , err )
91
+ }
92
+ log .Debugln ("Response of lsmdiskgrp: " , mDiskGrpResp )
93
+ // This is a sample output of lsmdiskgrp
94
+ // [
95
+ // {
96
+ // "id": "0",
97
+ // "name": "Pool0",
98
+ // "status": "online",
99
+ // "mdisk_count": "1",
100
+ // "vdisk_count": "5",
101
+ // "capacity": "99.01TB",
102
+ // "extent_size": "1024",
103
+ // "free_capacity": "98.46TB",
104
+ // "virtual_capacity": "656.00GB",
105
+ // "used_capacity": "556.00GB",
106
+ // "real_capacity": "558.02GB",
107
+ // "overallocation": "0",
108
+ // "warning": "80",
109
+ // "easy_tier": "auto",
110
+ // "easy_tier_status": "balanced",
111
+ // "compression_active": "no",
112
+ // "compression_virtual_capacity": "0.00MB",
113
+ // "compression_compressed_capacity": "0.00MB",
114
+ // "compression_uncompressed_capacity": "0.00MB",
115
+ // "parent_mdisk_grp_id": "0",
116
+ // "parent_mdisk_grp_name": "Pool0",
117
+ // "child_mdisk_grp_count": "0",
118
+ // "child_mdisk_grp_capacity": "0.00MB",
119
+ // "type": "parent",
120
+ // "encrypt": "no",
121
+ // "owner_type": "none",
122
+ // "site_id": "",
123
+ // "site_name": "",
124
+ // "data_reduction": "no",
125
+ // "used_capacity_before_reduction": "0.00MB",
126
+ // "used_capacity_after_reduction": "0.00MB",
127
+ // "overhead_capacity": "0.00MB",
128
+ // "deduplication_capacity_saving": "0.00MB",
129
+ // "reclaimable_capacity": "0.00MB"
130
+ // }
131
+ // ]
132
+
133
+ mDiskGrpArray := gjson .Parse (mDiskGrpResp ).Array ()
90
134
for _ , mdiskgrp := range mDiskGrpArray {
91
135
mdiskgrp_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("capacity" ).String ())
136
+ if err != nil {
137
+ log .Errorf ("Converting capacity unit failed: %s" , err )
138
+ }
92
139
ch <- prometheus .MustNewConstMetric (mdiskgrp_capacity , prometheus .GaugeValue , float64 (mdiskgrp_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
93
140
94
141
extent_size_bytes , err := utils .ToBytes (mdiskgrp .Get ("extent_size" ).String () + "MB" )
142
+ if err != nil {
143
+ log .Errorf ("Converting capacity unit failed: %s" , err )
144
+ }
95
145
ch <- prometheus .MustNewConstMetric (extent_size , prometheus .GaugeValue , float64 (extent_size_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
96
146
97
147
free_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("free_capacity" ).String ())
148
+ if err != nil {
149
+ log .Errorf ("Converting capacity unit failed: %s" , err )
150
+ }
98
151
ch <- prometheus .MustNewConstMetric (free_capacity , prometheus .GaugeValue , float64 (free_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
99
152
100
153
virtual_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("virtual_capacity" ).String ())
154
+ if err != nil {
155
+ log .Errorf ("Converting capacity unit failed: %s" , err )
156
+ }
101
157
ch <- prometheus .MustNewConstMetric (virtual_capacity , prometheus .GaugeValue , float64 (virtual_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
102
158
103
159
used_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("used_capacity" ).String ())
160
+ if err != nil {
161
+ log .Errorf ("Converting capacity unit failed: %s" , err )
162
+ }
104
163
ch <- prometheus .MustNewConstMetric (used_capacity , prometheus .GaugeValue , float64 (used_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
105
164
106
165
real_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("real_capacity" ).String ())
166
+ if err != nil {
167
+ log .Errorf ("Converting capacity unit failed: %s" , err )
168
+ }
107
169
ch <- prometheus .MustNewConstMetric (real_capacity , prometheus .GaugeValue , float64 (real_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
108
170
109
171
overallocation_pc , err := strconv .ParseFloat (mdiskgrp .Get ("overallocation" ).String (), 64 )
172
+ if err != nil {
173
+ log .Errorf ("Converting capacity unit failed: %s" , err )
174
+ }
110
175
ch <- prometheus .MustNewConstMetric (overallocation , prometheus .GaugeValue , float64 (overallocation_pc ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
111
176
112
177
mdiskgrp_compression_active_value , err := utils .ToBool (mdiskgrp .Get ("compression_active" ).String ())
178
+ if err != nil {
179
+ log .Errorf ("Converting capacity unit failed: %s" , err )
180
+ }
113
181
ch <- prometheus .MustNewConstMetric (mdiskgrp_compression_active , prometheus .GaugeValue , mdiskgrp_compression_active_value , sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
114
182
115
183
mdiskgrp_compression_virtual_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("compression_virtual_capacity" ).String ())
184
+ if err != nil {
185
+ log .Errorf ("Converting capacity unit failed: %s" , err )
186
+ }
116
187
ch <- prometheus .MustNewConstMetric (mdiskgrp_compression_virtual_capacity , prometheus .GaugeValue , float64 (mdiskgrp_compression_virtual_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
117
188
118
189
mdiskgrp_compression_compressed_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("compression_compressed_capacity" ).String ())
190
+ if err != nil {
191
+ log .Errorf ("Converting capacity unit failed: %s" , err )
192
+ }
119
193
ch <- prometheus .MustNewConstMetric (mdiskgrp_compression_compressed_capacity , prometheus .GaugeValue , float64 (mdiskgrp_compression_compressed_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
120
194
121
195
mdiskgrp_compression_uncompressed_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("compression_uncompressed_capacity" ).String ())
196
+ if err != nil {
197
+ log .Errorf ("Converting capacity unit failed: %s" , err )
198
+ }
122
199
ch <- prometheus .MustNewConstMetric (mdiskgrp_compression_uncompressed_capacity , prometheus .GaugeValue , float64 (mdiskgrp_compression_uncompressed_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
123
200
124
201
mdiskgrp_used_capacity_before_reduction_bytes , err := utils .ToBytes (mdiskgrp .Get ("used_capacity_before_reduction" ).String ())
202
+ if err != nil {
203
+ log .Errorf ("Converting capacity unit failed: %s" , err )
204
+ }
125
205
ch <- prometheus .MustNewConstMetric (mdiskgrp_used_capacity_before_reduction , prometheus .GaugeValue , float64 (mdiskgrp_used_capacity_before_reduction_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
126
206
127
207
mdiskgrp_used_capacity_after_reduction_bytes , err := utils .ToBytes (mdiskgrp .Get ("used_capacity_after_reduction" ).String ())
208
+ if err != nil {
209
+ log .Errorf ("Converting capacity unit failed: %s" , err )
210
+ }
128
211
ch <- prometheus .MustNewConstMetric (mdiskgrp_used_capacity_after_reduction , prometheus .GaugeValue , float64 (mdiskgrp_used_capacity_after_reduction_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
129
212
130
213
mdiskgrp_overhead_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("overhead_capacity" ).String ())
214
+ if err != nil {
215
+ log .Errorf ("Converting capacity unit failed: %s" , err )
216
+ }
131
217
ch <- prometheus .MustNewConstMetric (mdiskgrp_overhead_capacity , prometheus .GaugeValue , float64 (mdiskgrp_overhead_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
132
218
133
219
mdiskgrp_deduplication_capcacity_saving_bytes , err := utils .ToBytes (mdiskgrp .Get ("deduplication_capacity_saving" ).String ())
220
+ if err != nil {
221
+ log .Errorf ("Converting capacity unit failed: %s" , err )
222
+ }
134
223
ch <- prometheus .MustNewConstMetric (mdiskgrp_deduplication_capcacity_saving , prometheus .GaugeValue , float64 (mdiskgrp_deduplication_capcacity_saving_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
135
224
136
225
reclaimable_capacity_bytes , err := utils .ToBytes (mdiskgrp .Get ("reclaimable_capacity" ).String ())
137
- ch <- prometheus .MustNewConstMetric (reclaimable_capacity , prometheus .GaugeValue , float64 (reclaimable_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
138
226
if err != nil {
139
- return err
227
+ log . Errorf ( "Converting capacity unit failed: %s" , err )
140
228
}
229
+ ch <- prometheus .MustNewConstMetric (reclaimable_capacity , prometheus .GaugeValue , float64 (reclaimable_capacity_bytes ), sClient .IpAddress , sClient .Hostname , mdiskgrp .Get ("name" ).String (), mdiskgrp .Get ("status" ).String ())
141
230
142
231
}
232
+ log .Debugln ("Leaving MDiskgrp collector." )
143
233
return err
144
234
145
235
}
0 commit comments