Skip to content

Commit

Permalink
fix hostname label in device_info
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimkk-moideen committed Apr 24, 2024
1 parent 67a6ae7 commit 704fd52
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
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

0 comments on commit 704fd52

Please sign in to comment.