diff --git a/exporter/handlers.go b/exporter/handlers.go index 789ad54..0fef0c7 100644 --- a/exporter/handlers.go +++ b/exporter/handlers.go @@ -267,8 +267,8 @@ func (e *Exporter) exportPhysicalDriveMetrics(body []byte) error { state = BAD } - if dlphysical.Location != "" { - loc = dlphysical.Location + if dlphysical.LocationWrap.Location != "" { + loc = dlphysical.LocationWrap.Location } else if dlphysical.PhysicalLocation.PartLocation.ServiceLabel != "" { loc = dlphysical.PhysicalLocation.PartLocation.ServiceLabel } diff --git a/exporter/helpers.go b/exporter/helpers.go index c97f40f..c2b2002 100644 --- a/exporter/helpers.go +++ b/exporter/helpers.go @@ -156,7 +156,7 @@ func getSystemEndpoints(chassisUrls []string, host string, client *retryablehttp for _, drive := range chas.Links.Drives.LinksURLSlice { url := appendSlash(drive) // this list can potentially be large and cause scrapes to take a long time please - // see the '--collector.drives.module-exclude' config in the README for more information + // see the '--collector.drives.modules-exclude' config in the README for more information if reg, ok := excludes["drive"]; ok { if !reg.(*regexp.Regexp).MatchString(url) { if checkUnique(sysEnd.drives, url) { @@ -173,7 +173,7 @@ func getSystemEndpoints(chassisUrls []string, host string, client *retryablehttp for _, drive := range chas.LinksLower.Drives.LinksURLSlice { url := appendSlash(drive) // this list can potentially be large and cause scrapes to take a long time please - // see the '--collector.drives.module-exclude' config in the README for more information + // see the '--collector.drives.modules-exclude' config in the README for more information if reg, ok := excludes["drive"]; ok { if !reg.(*regexp.Regexp).MatchString(url) { if checkUnique(sysEnd.drives, url) { diff --git a/helm/fishymetrics/templates/deployment.yaml b/helm/fishymetrics/templates/deployment.yaml index 0a768c7..7770988 100644 --- a/helm/fishymetrics/templates/deployment.yaml +++ b/helm/fishymetrics/templates/deployment.yaml @@ -53,7 +53,7 @@ spec: - --credentials.profiles={{ toJson .Values.credentials }} {{- end }} {{- if .Values.collector.drives.modulesExclude }} - - --collector.drives.modules-exclude={{ .Values.collector.drives.modulesExclude | quote }} + - --collector.drives.modules-exclude={{ .Values.collector.drives.modulesExclude }} {{- end }} env: - name: BMC_USERNAME @@ -77,7 +77,6 @@ spec: key: vault-secret-id - name: EXPORTER_PORT value: {{ .Values.exporter.port | quote }} - {{- if .Values.vector.enabled }} - name: LOG_LEVEL value: {{ .Values.log.level }} - name: LOG_METHOD @@ -90,6 +89,7 @@ spec: value: {{ .Values.log.fileMaxBackups | quote }} - name: LOG_FILE_MAX_AGE value: {{ .Values.log.fileMaxAge | quote }} + {{- if .Values.vector.enabled }} - name: VECTOR_ENDPOINT value: {{ .Values.vector.endpoint }} {{- end }} diff --git a/oem/drive.go b/oem/drive.go index 8290119..e095f87 100644 --- a/oem/drive.go +++ b/oem/drive.go @@ -16,6 +16,11 @@ package oem +import ( + "bytes" + "encoding/json" +) + // /redfish/v1/Systems/X/SmartStorage/ArrayControllers/ type DriveProtocol struct { @@ -54,7 +59,8 @@ type LogicalDriveMetrics struct { } // Disk Drives -// /redfish/v1/Systems/X/SmartStorage/ArrayControllers/X/DiskDrives/X/ +// /redfish/v1/Systems/XXXXX/SmartStorage/ArrayControllers/X/DiskDrives/X/ +// /redfish/v1/Systems/XXXXX/Storage/XXXXX/Drives/PD-XX/ type DiskDriveMetrics struct { Id string `json:"Id"` CapacityMiB int `json:"CapacityMiB"` @@ -64,11 +70,35 @@ type DiskDriveMetrics struct { Name string `json:"Name"` Model string `json:"Model"` Status Status `json:"Status"` - Location string `json:"Location"` + LocationWrap LocationWrapper `json:"Location"` PhysicalLocation PhysicalLocation `json:"PhysicalLocation"` SerialNumber string `json:"SerialNumber"` } +type LocationWrapper struct { + Location string +} + +func (w *LocationWrapper) UnmarshalJSON(data []byte) error { + // because of a change in output between firmware versions we need to account for this + if bytes.Compare([]byte("[{"), data[0:2]) == 0 { + var locTmp []struct { + Loc string `json:"Info,omitempty"` + } + err := json.Unmarshal(data, &locTmp) + if len(locTmp) > 0 { + for _, l := range locTmp { + if l.Loc != "" { + w.Location = l.Loc + } + } + return nil + } + return err + } + return json.Unmarshal(data, &w.Location) +} + // GenericDrive is used to iterate over differing drive endpoints // /redfish/v1/Systems/X/SmartStorage/ArrayControllers/ for Logical and Physical Drives // /redfish/v1/Chassis/X/Drives/ for NVMe Drive(s)