Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix extra quotes in helm chart template, fix json unmarshal bug with … #67

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exporter/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions helm/fishymetrics/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
34 changes: 32 additions & 2 deletions oem/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

package oem

import (
"bytes"
"encoding/json"
)

// /redfish/v1/Systems/X/SmartStorage/ArrayControllers/

type DriveProtocol struct {
Expand Down Expand Up @@ -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"`
Expand All @@ -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)
Expand Down
Loading