Skip to content

Commit 704fd52

Browse files
fix hostname label in device_info
1 parent 67a6ae7 commit 704fd52

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

exporter/exporter.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ var (
7979
// Exporter collects chassis manager stats from the given URI and exports them using
8080
// the prometheus metrics package.
8181
type Exporter struct {
82-
ctx context.Context
83-
mutex sync.RWMutex
84-
pool *pool.Pool
85-
client *retryablehttp.Client
86-
host string
87-
url string
88-
credProfile string
89-
biosVersion string
90-
82+
ctx context.Context
83+
mutex sync.RWMutex
84+
pool *pool.Pool
85+
client *retryablehttp.Client
86+
host string
87+
url string
88+
credProfile string
89+
biosVersion string
90+
systemHostname string
9191
ChassisSerialNumber string
9292
DeviceMetrics *map[string]*metrics
9393
Model string
@@ -255,6 +255,7 @@ func NewExporter(ctx context.Context, target, uri, profile, model string, exclud
255255
}
256256
exp.biosVersion = sysResp.BiosVersion
257257
exp.ChassisSerialNumber = sysResp.SerialNumber
258+
exp.systemHostname = sysResp.SystemHostname
258259

259260
// call /redfish/v1/Systems/XXXXX/ for memory summary and smart storage batteries
260261
// TODO: do not assume 1 systems endpoint

exporter/exporter_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const (
3838
GoodDeviceInfoExpected = `
3939
# HELP redfish_device_info Current snapshot of device firmware information
4040
# TYPE redfish_device_info gauge
41-
redfish_device_info{biosVersion="U99 v0.00 (xx/xx/xxxx)",chassisModel="model a",chassisSerialNumber="SN98765",firmwareVersion="iLO 5 v2.65",name="test description"} 1
41+
redfish_device_info{biosVersion="U99 v0.00 (xx/xx/xxxx)",chassisModel="model a",chassisSerialNumber="SN98765",firmwareVersion="iLO 5 v2.65",name="hostname123"} 1
4242
`
4343
GoodCPUStatusExpected = `
4444
# HELP redfish_cpu_status Current cpu status 1 = OK, 0 = BAD
@@ -1110,6 +1110,7 @@ func Test_Exporter_Metrics_Handling(t *testing.T) {
11101110
host: "fishymetrics.com",
11111111
Model: "model a",
11121112
biosVersion: "U99 v0.00 (xx/xx/xxxx)",
1113+
systemHostname: "hostname123",
11131114
ChassisSerialNumber: "SN98765",
11141115
DeviceMetrics: NewDeviceMetrics(),
11151116
}

exporter/handlers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (e *Exporter) exportFirmwareMetrics(body []byte) error {
7171
return fmt.Errorf("Error Unmarshalling FirmwareMetrics - " + err.Error())
7272
}
7373

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

7676
return nil
7777
}

oem/system.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ package oem
2121
// ServerManager contains the BIOS version and Serial number of the chassis,
2222
// we will also collect memory summary and storage battery metrics if present
2323
type System struct {
24-
BiosVersion string `json:"BiosVersion"`
25-
SerialNumber string `json:"SerialNumber"`
26-
IloServerName string `json:"HostName"`
27-
Oem OemSys `json:"Oem"`
28-
MemorySummary MemorySummary `json:"MemorySummary"`
24+
BiosVersion string `json:"BiosVersion"`
25+
SerialNumber string `json:"SerialNumber"`
26+
SystemHostname string `json:"HostName"`
27+
Oem OemSys `json:"Oem"`
28+
MemorySummary MemorySummary `json:"MemorySummary"`
2929
}
3030

3131
type OemSys struct {

0 commit comments

Comments
 (0)