From 842460ad359807176b1424aa3195166109c162e5 Mon Sep 17 00:00:00 2001 From: ibrahimkk-moideen Date: Fri, 5 Apr 2024 11:17:54 -0400 Subject: [PATCH] firmware collection and device info metric name fix --- hpe/dl360/exporter.go | 10 +++++----- hpe/dl380/exporter.go | 7 +++++-- hpe/dl560/exporter.go | 6 ++++-- hpe/xl420/exporter.go | 7 +++++-- oem/chassis.go | 5 +++-- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/hpe/dl360/exporter.go b/hpe/dl360/exporter.go index f112c77..b3f7b2e 100644 --- a/hpe/dl360/exporter.go +++ b/hpe/dl360/exporter.go @@ -88,6 +88,7 @@ type Exporter struct { credProfile string biosVersion string chassisSerialNumber string + iloServerName string deviceMetrics *map[string]*metrics } @@ -177,6 +178,7 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e } exp.biosVersion = resp.BiosVersion exp.chassisSerialNumber = resp.SerialNumber + exp.iloServerName = resp.IloServerName // vars for drive parsing var ( @@ -309,14 +311,12 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e return nil, err } - tasks = append(tasks, - pool.NewTask(common.Fetch(fqdn.String()+uri+"/Managers/1", FIRMWARE, target, profile, retryClient))) - // Additional tasks for pool to perform tasks = append(tasks, pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Thermal/", THERMAL, target, profile, retryClient)), pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Power/", POWER, target, profile, retryClient)), - pool.NewTask(common.Fetch(fqdn.String()+uri+"/Systems/1/", MEMORY_SUMMARY, target, profile, retryClient))) + pool.NewTask(common.Fetch(fqdn.String()+uri+"/Systems/1/", MEMORY_SUMMARY, target, profile, retryClient)), + pool.NewTask(common.Fetch(fqdn.String()+uri+"/Managers/1/", FIRMWARE, target, profile, retryClient))) // DIMMs for _, dimm := range dimms.Members { @@ -474,7 +474,7 @@ func (e *Exporter) exportFirmwareMetrics(body []byte) error { return fmt.Errorf("Error Unmarshalling DL360 FirmwareMetrics - " + err.Error()) } - (*dm)["deviceInfo"].WithLabelValues(chas.Description, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, DL360).Set(1.0) + (*dm)["deviceInfo"].WithLabelValues(e.iloServerName, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, DL360).Set(1.0) return nil } diff --git a/hpe/dl380/exporter.go b/hpe/dl380/exporter.go index 267b78c..7ebfdd7 100644 --- a/hpe/dl380/exporter.go +++ b/hpe/dl380/exporter.go @@ -82,6 +82,7 @@ type Exporter struct { credProfile string biosVersion string chassisSerialNumber string + iloServerName string deviceMetrics *map[string]*metrics } @@ -171,6 +172,7 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e } exp.biosVersion = resp.BiosVersion exp.chassisSerialNumber = resp.SerialNumber + exp.iloServerName = resp.IloServerName // vars for drive parsing var ( @@ -305,7 +307,8 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e tasks = append(tasks, pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Thermal/", THERMAL, target, profile, retryClient)), pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Power/", POWER, target, profile, retryClient)), - pool.NewTask(common.Fetch(fqdn.String()+uri+"/Systems/1/", MEMORY_SUMMARY, target, profile, retryClient))) + pool.NewTask(common.Fetch(fqdn.String()+uri+"/Systems/1/", MEMORY_SUMMARY, target, profile, retryClient)), + pool.NewTask(common.Fetch(fqdn.String()+uri+"/Managers/1/", FIRMWARE, target, profile, retryClient))) // DIMMs for _, dimm := range dimms.Members { @@ -442,7 +445,7 @@ func (e *Exporter) exportFirmwareMetrics(body []byte) error { return fmt.Errorf("Error Unmarshalling DL380 FirmwareMetrics - " + err.Error()) } - (*dm)["deviceInfo"].WithLabelValues(chas.Description, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, DL380).Set(1.0) + (*dm)["deviceInfo"].WithLabelValues(e.iloServerName, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, DL380).Set(1.0) return nil } diff --git a/hpe/dl560/exporter.go b/hpe/dl560/exporter.go index 94b7f37..c4c6e09 100644 --- a/hpe/dl560/exporter.go +++ b/hpe/dl560/exporter.go @@ -82,6 +82,7 @@ type Exporter struct { credProfile string biosVersion string chassisSerialNumber string + iloServerName string deviceMetrics *map[string]*metrics } @@ -171,6 +172,7 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e } exp.biosVersion = resp.BiosVersion exp.chassisSerialNumber = resp.SerialNumber + exp.iloServerName = resp.IloServerName // vars for drive parsing var ( @@ -298,7 +300,7 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Thermal/", THERMAL, target, profile, retryClient)), pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Power/", POWER, target, profile, retryClient)), pool.NewTask(common.Fetch(fqdn.String()+uri+"/Systems/1/", MEMORY_SUMMARY, target, profile, retryClient)), - ) + pool.NewTask(common.Fetch(fqdn.String()+uri+"/Managers/1/", FIRMWARE, target, profile, retryClient))) // DIMMs for _, dimm := range dimms.Members { @@ -435,7 +437,7 @@ func (e *Exporter) exportFirmwareMetrics(body []byte) error { return fmt.Errorf("Error Unmarshalling DL560 FirmwareMetrics - " + err.Error()) } - (*dm)["deviceInfo"].WithLabelValues(chas.Description, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, DL560).Set(1.0) + (*dm)["deviceInfo"].WithLabelValues(e.iloServerName, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, DL560).Set(1.0) return nil } diff --git a/hpe/xl420/exporter.go b/hpe/xl420/exporter.go index 57f4789..21377f1 100644 --- a/hpe/xl420/exporter.go +++ b/hpe/xl420/exporter.go @@ -88,6 +88,7 @@ type Exporter struct { credProfile string biosVersion string chassisSerialNumber string + iloServerName string deviceMetrics *map[string]*metrics } @@ -177,6 +178,7 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e } exp.biosVersion = resp.BiosVersion exp.chassisSerialNumber = resp.SerialNumber + exp.iloServerName = resp.IloServerName // vars for drive parsing var ( @@ -312,7 +314,8 @@ func NewExporter(ctx context.Context, target, uri, profile string) (*Exporter, e tasks = append(tasks, pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Thermal/", THERMAL, target, profile, retryClient)), pool.NewTask(common.Fetch(fqdn.String()+uri+"/Chassis/1/Power/", POWER, target, profile, retryClient)), - pool.NewTask(common.Fetch(fqdn.String()+uri+"/Systems/1/", MEMORY_SUMMARY, target, profile, retryClient))) + pool.NewTask(common.Fetch(fqdn.String()+uri+"/Systems/1/", MEMORY_SUMMARY, target, profile, retryClient)), + pool.NewTask(common.Fetch(fqdn.String()+uri+"/Managers/1/", FIRMWARE, target, profile, retryClient))) // DIMMs for _, dimm := range dimms.Members { @@ -470,7 +473,7 @@ func (e *Exporter) exportFirmwareMetrics(body []byte) error { return fmt.Errorf("Error Unmarshalling XL420 FirmwareMetrics - " + err.Error()) } - (*dm)["deviceInfo"].WithLabelValues(chas.Description, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, XL420).Set(1.0) + (*dm)["deviceInfo"].WithLabelValues(e.iloServerName, e.chassisSerialNumber, chas.FirmwareVersion, e.biosVersion, XL420).Set(1.0) return nil } diff --git a/oem/chassis.go b/oem/chassis.go index 76d0ba8..1d8efd0 100644 --- a/oem/chassis.go +++ b/oem/chassis.go @@ -86,8 +86,9 @@ type Status struct { // ServerManager contains the BIOS version and Serial number of the chassis type ServerManager struct { - BiosVersion string `json:"BiosVersion"` - SerialNumber string `json:"SerialNumber"` + BiosVersion string `json:"BiosVersion"` + SerialNumber string `json:"SerialNumber"` + IloServerName string `json:"HostName"` } // /redfish/v1/Chassis/CMC