Skip to content

Commit a653417

Browse files
remove trailing spaces in labels value
1 parent 6ae8d65 commit a653417

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

exporter/handlers.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (e *Exporter) exportPowerMetrics(body []byte) error {
166166
}
167167

168168
if watts != 9999 {
169-
(*pow)["supplyOutput"].WithLabelValues(ps.Name, e.ChassisSerialNumber, e.Model, strings.TrimRight(ps.Manufacturer, " "), ps.SerialNumber, ps.FirmwareVersion, ps.PowerSupplyType, strconv.Itoa(bay), ps.Model).Set(watts)
169+
(*pow)["supplyOutput"].WithLabelValues(ps.Name, e.ChassisSerialNumber, e.Model, strings.TrimRight(ps.Manufacturer, " "), strings.TrimRight(ps.SerialNumber, " "), ps.FirmwareVersion, ps.PowerSupplyType, strconv.Itoa(bay), strings.TrimRight(ps.Model, " ")).Set(watts)
170170
}
171171
if ps.Status.Health == "OK" || ps.Status.Health == "Ok" {
172172
state = OK
@@ -180,7 +180,7 @@ func (e *Exporter) exportPowerMetrics(body []byte) error {
180180
}
181181

182182
if ps.Status.State != "Absent" {
183-
(*pow)["supplyStatus"].WithLabelValues(ps.Name, e.ChassisSerialNumber, e.Model, strings.TrimRight(ps.Manufacturer, " "), ps.SerialNumber, ps.FirmwareVersion, ps.PowerSupplyType, strconv.Itoa(bay), ps.Model).Set(state)
183+
(*pow)["supplyStatus"].WithLabelValues(ps.Name, e.ChassisSerialNumber, e.Model, strings.TrimRight(ps.Manufacturer, " "), strings.TrimRight(ps.SerialNumber, " "), ps.FirmwareVersion, ps.PowerSupplyType, strconv.Itoa(bay), strings.TrimRight(ps.Model, " ")).Set(state)
184184
}
185185
}
186186

@@ -309,7 +309,7 @@ func (e *Exporter) exportPhysicalDriveMetrics(body []byte) error {
309309

310310
// Physical drives need to have a unique identifier like location so as to not overwrite data
311311
// physical drives can have the same ID, but belong to a different ArrayController, therefore need more than just the ID as a unique identifier.
312-
(*dlphysicaldrive)["driveStatus"].WithLabelValues(dlphysical.Name, e.ChassisSerialNumber, e.Model, dlphysical.Id, loc, dlphysical.SerialNumber, strconv.Itoa(cap)).Set(state)
312+
(*dlphysicaldrive)["driveStatus"].WithLabelValues(dlphysical.Name, e.ChassisSerialNumber, e.Model, dlphysical.Id, loc, strings.TrimRight(dlphysical.SerialNumber, " "), strconv.Itoa(cap)).Set(state)
313313
return nil
314314
}
315315

@@ -347,7 +347,7 @@ func (e *Exporter) exportLogicalDriveMetrics(body []byte) error {
347347
state = DISABLED
348348
}
349349

350-
(*dllogicaldrive)["raidStatus"].WithLabelValues(dllogical.Name, e.ChassisSerialNumber, e.Model, ldName, volIdentifier, raidType).Set(state)
350+
(*dllogicaldrive)["raidStatus"].WithLabelValues(strings.TrimRight(dllogical.Name, " "), e.ChassisSerialNumber, e.Model, strings.TrimRight(ldName, " "), volIdentifier, raidType).Set(state)
351351
return nil
352352
}
353353

@@ -420,7 +420,7 @@ func (e *Exporter) exportStorageControllerMetrics(body []byte) error {
420420
} else {
421421
state = BAD
422422
}
423-
(*drv)["storageControllerStatus"].WithLabelValues(scm.Name, e.ChassisSerialNumber, e.Model, sc.FirmwareVersion, sc.Model, sc.Location.Location).Set(state)
423+
(*drv)["storageControllerStatus"].WithLabelValues(strings.TrimRight(scm.Name, " "), e.ChassisSerialNumber, e.Model, sc.FirmwareVersion, strings.TrimRight(sc.Model, " "), sc.Location.Location).Set(state)
424424
}
425425
}
426426

@@ -431,7 +431,7 @@ func (e *Exporter) exportStorageControllerMetrics(body []byte) error {
431431
} else {
432432
state = BAD
433433
}
434-
(*drv)["storageControllerStatus"].WithLabelValues(scm.Name, e.ChassisSerialNumber, e.Model, scm.ControllerFirmware.FirmwareVersion, scm.Model, scm.Location.Location).Set(state)
434+
(*drv)["storageControllerStatus"].WithLabelValues(strings.TrimRight(scm.Name, " "), e.ChassisSerialNumber, e.Model, scm.ControllerFirmware.FirmwareVersion, strings.TrimRight(scm.Model, " "), scm.Location.Location).Set(state)
435435
}
436436
}
437437

@@ -642,7 +642,7 @@ func (e *Exporter) exportProcessorMetrics(body []byte) error {
642642
} else {
643643
state = BAD
644644
}
645-
(*proc)["processorStatus"].WithLabelValues(pm.Id, e.ChassisSerialNumber, e.Model, pm.Socket, pm.Model, totCores).Set(state)
645+
(*proc)["processorStatus"].WithLabelValues(pm.Id, e.ChassisSerialNumber, e.Model, pm.Socket, strings.TrimRight(pm.Model, " "), totCores).Set(state)
646646

647647
return nil
648648
}
@@ -659,7 +659,7 @@ func (e *Exporter) exportFirmwareInventoryMetrics(body []byte) error {
659659
// Export for iLO4 since it has a different structure
660660
if len(fwcomponent.Current.Firmware) > 0 {
661661
for _, firmware := range fwcomponent.Current.Firmware {
662-
(*component)["componentFirmware"].WithLabelValues(firmware.Id, firmware.Name, firmware.Location, firmware.VersionString).Set(1.0)
662+
(*component)["componentFirmware"].WithLabelValues(firmware.Id, strings.TrimRight(firmware.Name, " "), firmware.Location, firmware.VersionString).Set(1.0)
663663
}
664664
} else {
665665
// Export for iLO5, since it's structure matches the GenericFirmware struct
@@ -669,7 +669,7 @@ func (e *Exporter) exportFirmwareInventoryMetrics(body []byte) error {
669669
return fmt.Errorf("Error Unmarshalling FirmwareInventoryMetrics - " + err.Error())
670670
}
671671

672-
(*component)["componentFirmware"].WithLabelValues(fwcomponent.Id, fwcomponent.Name, fwcomponent.Description, fwcomponent.Version).Set(1.0)
672+
(*component)["componentFirmware"].WithLabelValues(fwcomponent.Id, strings.TrimRight(fwcomponent.Name, " "), fwcomponent.Description, fwcomponent.Version).Set(1.0)
673673
}
674674
return nil
675675
}

0 commit comments

Comments
 (0)