@@ -182,6 +182,17 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
182
182
// get system OdataID
183
183
//systemOdataID := system.ODataID
184
184
185
+ wg1 := & sync.WaitGroup {}
186
+ wg2 := & sync.WaitGroup {}
187
+ wg3 := & sync.WaitGroup {}
188
+ wg4 := & sync.WaitGroup {}
189
+ wg5 := & sync.WaitGroup {}
190
+ wg6 := & sync.WaitGroup {}
191
+ wg7 := & sync.WaitGroup {}
192
+ wg8 := & sync.WaitGroup {}
193
+ wg9 := & sync.WaitGroup {}
194
+ wg10 := & sync.WaitGroup {}
195
+
185
196
// process memory metrics
186
197
// construct memory Link
187
198
//memoriesLink := fmt.Sprintf("%sMemory/", systemOdataID)
@@ -193,7 +204,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
193
204
} else if memories == nil {
194
205
systemLogContext .WithField ("operation" , "system.Memory()" ).Info ("no memory data found" )
195
206
} else {
196
- wg1 := & sync.WaitGroup {}
197
207
wg1 .Add (len (memories ))
198
208
199
209
for _ , memory := range memories {
@@ -212,7 +222,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
212
222
} else if processors == nil {
213
223
systemLogContext .WithField ("operation" , "system.Processors()" ).Info ("no processor data found" )
214
224
} else {
215
- wg2 := & sync.WaitGroup {}
216
225
wg2 .Add (len (processors ))
217
226
218
227
for _ , processor := range processors {
@@ -235,7 +244,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
235
244
if volumes , err := storage .Volumes (); err != nil {
236
245
systemLogContext .WithField ("operation" , "system.Volumes()" ).WithError (err ).Error ("error getting storage data from system" )
237
246
} else {
238
- wg3 := & sync.WaitGroup {}
239
247
wg3 .Add (len (volumes ))
240
248
241
249
for _ , volume := range volumes {
@@ -249,7 +257,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
249
257
} else if drives == nil {
250
258
systemLogContext .WithFields (log.Fields {"operation" : "system.Drives()" , "storage" : storage .ID }).Info ("no drive data found" )
251
259
} else {
252
- wg4 := & sync.WaitGroup {}
253
260
wg4 .Add (len (drives ))
254
261
for _ , drive := range drives {
255
262
go parseDrive (ch , systemHostName , drive , wg4 )
@@ -290,7 +297,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
290
297
} else if pcieDevices == nil {
291
298
systemLogContext .WithField ("operation" , "system.PCIeDevices()" ).Info ("no PCI-E device data found" )
292
299
} else {
293
- wg5 := & sync.WaitGroup {}
294
300
wg5 .Add (len (pcieDevices ))
295
301
for _ , pcieDevice := range pcieDevices {
296
302
go parsePcieDevice (ch , systemHostName , pcieDevice , wg5 )
@@ -304,7 +310,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
304
310
} else if networkInterfaces == nil {
305
311
systemLogContext .WithField ("operation" , "system.NetworkInterfaces()" ).Info ("no network interface data found" )
306
312
} else {
307
- wg6 := & sync.WaitGroup {}
308
313
wg6 .Add (len (networkInterfaces ))
309
314
for _ , networkInterface := range networkInterfaces {
310
315
go parseNetworkInterface (ch , systemHostName , networkInterface , wg6 )
@@ -318,7 +323,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
318
323
} else if ethernetInterfaces == nil {
319
324
systemLogContext .WithField ("operation" , "system.PCIeDevices()" ).Info ("no ethernet interface data found" )
320
325
} else {
321
- wg7 := & sync.WaitGroup {}
322
326
wg7 .Add (len (ethernetInterfaces ))
323
327
for _ , ethernetInterface := range ethernetInterfaces {
324
328
go parseEthernetInterface (ch , systemHostName , ethernetInterface , wg7 )
@@ -334,7 +338,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
334
338
} else {
335
339
for _ , simpleStorage := range simpleStorages {
336
340
devices := simpleStorage .Devices
337
- wg8 := & sync.WaitGroup {}
338
341
wg8 .Add (len (devices ))
339
342
for _ , device := range devices {
340
343
go parseDevice (ch , systemHostName , device , wg8 )
@@ -348,7 +351,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
348
351
} else if pcieFunctions == nil {
349
352
systemLogContext .WithField ("operation" , "system.PCIeFunctions()" ).Info ("no PCI-E device function data found" )
350
353
} else {
351
- wg9 := & sync.WaitGroup {}
352
354
wg9 .Add (len (pcieFunctions ))
353
355
for _ , pcieFunction := range pcieFunctions {
354
356
go parsePcieFunction (ch , systemHostName , pcieFunction , wg9 )
@@ -362,7 +364,6 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
362
364
} else if logServices == nil {
363
365
systemLogContext .WithField ("operation" , "system.LogServices()" ).Info ("no log services found" )
364
366
} else {
365
- wg10 := & sync.WaitGroup {}
366
367
wg10 .Add (len (logServices ))
367
368
368
369
for _ , logService := range logServices {
@@ -372,6 +373,17 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
372
373
}
373
374
}
374
375
376
+ wg1 .Wait ()
377
+ wg2 .Wait ()
378
+ wg3 .Wait ()
379
+ wg4 .Wait ()
380
+ wg5 .Wait ()
381
+ wg6 .Wait ()
382
+ wg7 .Wait ()
383
+ wg8 .Wait ()
384
+ wg9 .Wait ()
385
+ wg10 .Wait ()
386
+
375
387
systemLogContext .Info ("collector scrape completed" )
376
388
}
377
389
s .collectorScrapeStatus .WithLabelValues ("system" ).Set (float64 (1 ))
0 commit comments