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 hostname label in device_info #69

Merged
merged 1 commit into from
Apr 25, 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
19 changes: 10 additions & 9 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ var (
// Exporter collects chassis manager stats from the given URI and exports them using
// the prometheus metrics package.
type Exporter struct {
ctx context.Context
mutex sync.RWMutex
pool *pool.Pool
client *retryablehttp.Client
host string
url string
credProfile string
biosVersion string

ctx context.Context
mutex sync.RWMutex
pool *pool.Pool
client *retryablehttp.Client
host string
url string
credProfile string
biosVersion string
systemHostname string
ChassisSerialNumber string
DeviceMetrics *map[string]*metrics
Model string
Expand Down Expand Up @@ -255,6 +255,7 @@ func NewExporter(ctx context.Context, target, uri, profile, model string, exclud
}
exp.biosVersion = sysResp.BiosVersion
exp.ChassisSerialNumber = sysResp.SerialNumber
exp.systemHostname = sysResp.SystemHostname

// call /redfish/v1/Systems/XXXXX/ for memory summary and smart storage batteries
// TODO: do not assume 1 systems endpoint
Expand Down
3 changes: 2 additions & 1 deletion exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
GoodDeviceInfoExpected = `
# HELP redfish_device_info Current snapshot of device firmware information
# TYPE redfish_device_info gauge
redfish_device_info{biosVersion="U99 v0.00 (xx/xx/xxxx)",chassisModel="model a",chassisSerialNumber="SN98765",firmwareVersion="iLO 5 v2.65",name="test description"} 1
redfish_device_info{biosVersion="U99 v0.00 (xx/xx/xxxx)",chassisModel="model a",chassisSerialNumber="SN98765",firmwareVersion="iLO 5 v2.65",name="hostname123"} 1
`
GoodCPUStatusExpected = `
# HELP redfish_cpu_status Current cpu status 1 = OK, 0 = BAD
Expand Down Expand Up @@ -1110,6 +1110,7 @@ func Test_Exporter_Metrics_Handling(t *testing.T) {
host: "fishymetrics.com",
Model: "model a",
biosVersion: "U99 v0.00 (xx/xx/xxxx)",
systemHostname: "hostname123",
ChassisSerialNumber: "SN98765",
DeviceMetrics: NewDeviceMetrics(),
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (e *Exporter) exportFirmwareMetrics(body []byte) error {
return fmt.Errorf("Error Unmarshalling FirmwareMetrics - " + err.Error())
}

(*dm)["deviceInfo"].WithLabelValues(mgr.Description, e.ChassisSerialNumber, e.Model, mgr.FirmwareVersion, e.biosVersion).Set(1.0)
(*dm)["deviceInfo"].WithLabelValues(e.systemHostname, e.ChassisSerialNumber, e.Model, mgr.FirmwareVersion, e.biosVersion).Set(1.0)

return nil
}
Expand Down
10 changes: 5 additions & 5 deletions oem/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ package oem
// ServerManager contains the BIOS version and Serial number of the chassis,
// we will also collect memory summary and storage battery metrics if present
type System struct {
BiosVersion string `json:"BiosVersion"`
SerialNumber string `json:"SerialNumber"`
IloServerName string `json:"HostName"`
Oem OemSys `json:"Oem"`
MemorySummary MemorySummary `json:"MemorySummary"`
BiosVersion string `json:"BiosVersion"`
SerialNumber string `json:"SerialNumber"`
SystemHostname string `json:"HostName"`
Oem OemSys `json:"Oem"`
MemorySummary MemorySummary `json:"MemorySummary"`
}

type OemSys struct {
Expand Down
Loading