added member_id as tag(as it is a unique value) for redfish plugin and added address of the server when the status is other than 200 for better debugging (#8813)

This commit is contained in:
sarvanikonda 2021-02-17 21:47:13 +05:30 committed by GitHub
parent d9736d543f
commit 458f9d1e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 53 deletions

View File

@ -34,6 +34,7 @@ Telegraf minimum version: Telegraf 1.15.0
- redfish_thermal_temperatures - redfish_thermal_temperatures
- tags: - tags:
- source - source
- member_id
- address - address
- name - name
- datacenter (available only if location data is found) - datacenter (available only if location data is found)
@ -53,6 +54,7 @@ Telegraf minimum version: Telegraf 1.15.0
+ redfish_thermal_fans + redfish_thermal_fans
- tags: - tags:
- source - source
- member_id
- address - address
- name - name
- datacenter (available only if location data is found) - datacenter (available only if location data is found)
@ -73,6 +75,7 @@ Telegraf minimum version: Telegraf 1.15.0
- tags: - tags:
- source - source
- address - address
- member_id
- name - name
- datacenter (available only if location data is found) - datacenter (available only if location data is found)
- rack (available only if location data is found) - rack (available only if location data is found)
@ -92,6 +95,7 @@ Telegraf minimum version: Telegraf 1.15.0
- tags: - tags:
- source - source
- address - address
- member_id
- name - name
- datacenter (available only if location data is found) - datacenter (available only if location data is found)
- rack (available only if location data is found) - rack (available only if location data is found)
@ -110,18 +114,18 @@ Telegraf minimum version: Telegraf 1.15.0
### Example Output ### Example Output
``` ```
redfish_thermal_temperatures,source=test-hostname,name=CPU1,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=41,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_thermal_temperatures,source=test-hostname,name=CPU1,address=http://190.0.0.1,member_id="0"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=41,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_thermal_temperatures,source=test-hostname,name=CPU2,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=51,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_thermal_temperatures,source=test-hostname,name=CPU2,address=http://190.0.0.1,member_id="1"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=51,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_thermal_temperatures,source=test-hostname,name=SystemBoardInlet,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_thermal_temperatures,source=test-hostname,name=SystemBoardInlet,address=http://190.0.0.1,member_id="2"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_thermal_temperatures,source=test-hostname,name=SystemBoardExhaust,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=33,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_thermal_temperatures,source=test-hostname,name=SystemBoardExhaust,address=http://190.0.0.1,member_id="3"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=33,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_thermal_fans,source=test-hostname,name=SystemBoardFan1A,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17720,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_thermal_fans,source=test-hostname,name=SystemBoardFan1A,address=http://190.0.0.1,member_id="0"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17720,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_thermal_fans,source=test-hostname,name=SystemBoardFan1B,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17760,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_thermal_fans,source=test-hostname,name=SystemBoardFan1B,address=http://190.0.0.1,member_id="1"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17760,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_thermal_fans,source=test-hostname,name=SystemBoardFan2A,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17880,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_thermal_fans,source=test-hostname,name=SystemBoardFan2A,address=http://190.0.0.1,member_id="2"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17880,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_power_powersupplies,source=test-hostname,name=PS1Status,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=208,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 redfish_power_powersupplies,source=test-hostname,name=PS1Status,address=http://190.0.0.1,member_id="0"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=208,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000
redfish_power_powersupplies,source=test-hostname,name=PS2Status,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=194,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 redfish_power_powersupplies,source=test-hostname,name=PS2Status,address=http://190.0.0.1,member_id="1",datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=194,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000
redfish_power_voltages,source=test-hostname,name=CPU1MEM345,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_power_voltages,source=test-hostname,name=CPU1MEM345,address=http://190.0.0.1,member_id="0"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_power_voltages,source=test-hostname,name=CPU1MEM345,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_power_voltages,source=test-hostname,name=CPU1MEM345,address=http://190.0.0.1,member_id="1"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_power_voltages,source=test-hostname,name=CPU1MEM347,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_power_voltages,source=test-hostname,name=CPU1MEM347,address=http://190.0.0.1,member_id="2"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
redfish_power_voltages,source=test-hostname,name=PS1voltage1,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 redfish_power_voltages,source=test-hostname,name=PS1voltage1,address=http://190.0.0.1,member_id="12"datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000
``` ```

View File

@ -73,6 +73,7 @@ type Chassis struct {
type Power struct { type Power struct {
PowerSupplies []struct { PowerSupplies []struct {
Name string Name string
MemberId string
PowerInputWatts *float64 PowerInputWatts *float64
PowerCapacityWatts *float64 PowerCapacityWatts *float64
PowerOutputWatts *float64 PowerOutputWatts *float64
@ -82,6 +83,7 @@ type Power struct {
} }
Voltages []struct { Voltages []struct {
Name string Name string
MemberId string
ReadingVolts *float64 ReadingVolts *float64
UpperThresholdCritical *float64 UpperThresholdCritical *float64
UpperThresholdFatal *float64 UpperThresholdFatal *float64
@ -94,6 +96,7 @@ type Power struct {
type Thermal struct { type Thermal struct {
Fans []struct { Fans []struct {
Name string Name string
MemberId string
Reading *int64 Reading *int64
ReadingUnits *string ReadingUnits *string
UpperThresholdCritical *int64 UpperThresholdCritical *int64
@ -104,6 +107,7 @@ type Thermal struct {
} }
Temperatures []struct { Temperatures []struct {
Name string Name string
MemberId string
ReadingCelsius *float64 ReadingCelsius *float64
UpperThresholdCritical *float64 UpperThresholdCritical *float64
UpperThresholdFatal *float64 UpperThresholdFatal *float64
@ -189,9 +193,10 @@ func (r *Redfish) getData(url string, payload interface{}) error {
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
return fmt.Errorf("received status code %d (%s), expected 200", return fmt.Errorf("received status code %d (%s) for address %s, expected 200",
resp.StatusCode, resp.StatusCode,
http.StatusText(resp.StatusCode)) http.StatusText(resp.StatusCode),
r.Address)
} }
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
@ -271,6 +276,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range thermal.Temperatures { for _, j := range thermal.Temperatures {
tags := map[string]string{} tags := map[string]string{}
tags["member_id"] = j.MemberId
tags["address"] = address tags["address"] = address
tags["name"] = j.Name tags["name"] = j.Name
tags["source"] = system.Hostname tags["source"] = system.Hostname
@ -295,6 +301,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range thermal.Fans { for _, j := range thermal.Fans {
tags := map[string]string{} tags := map[string]string{}
fields := make(map[string]interface{}) fields := make(map[string]interface{})
tags["member_id"] = j.MemberId
tags["address"] = address tags["address"] = address
tags["name"] = j.Name tags["name"] = j.Name
tags["source"] = system.Hostname tags["source"] = system.Hostname
@ -326,6 +333,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range power.PowerSupplies { for _, j := range power.PowerSupplies {
tags := map[string]string{} tags := map[string]string{}
tags["member_id"] = j.MemberId
tags["address"] = address tags["address"] = address
tags["name"] = j.Name tags["name"] = j.Name
tags["source"] = system.Hostname tags["source"] = system.Hostname
@ -349,6 +357,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range power.Voltages { for _, j := range power.Voltages {
tags := map[string]string{} tags := map[string]string{}
tags["member_id"] = j.MemberId
tags["address"] = address tags["address"] = address
tags["name"] = j.Name tags["name"] = j.Name
tags["source"] = system.Hostname tags["source"] = system.Hostname

View File

@ -49,6 +49,7 @@ func TestDellApis(t *testing.T) {
"redfish_thermal_temperatures", "redfish_thermal_temperatures",
map[string]string{ map[string]string{
"name": "CPU1 Temp", "name": "CPU1 Temp",
"member_id": "iDRAC.Embedded.1#CPU1Temp",
"source": "tpa-hostname", "source": "tpa-hostname",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
@ -72,6 +73,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan1A", "name": "System Board Fan1A",
"member_id": "0x17||Fan.Embedded.1A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -92,6 +94,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan1B", "name": "System Board Fan1B",
"member_id": "0x17||Fan.Embedded.1B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -112,6 +115,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan2A", "name": "System Board Fan2A",
"member_id": "0x17||Fan.Embedded.2A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -132,6 +136,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan2B", "name": "System Board Fan2B",
"member_id": "0x17||Fan.Embedded.2B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -152,6 +157,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan3A", "name": "System Board Fan3A",
"member_id": "0x17||Fan.Embedded.3A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -172,6 +178,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan3B", "name": "System Board Fan3B",
"member_id": "0x17||Fan.Embedded.3B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -192,6 +199,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan4A", "name": "System Board Fan4A",
"member_id": "0x17||Fan.Embedded.4A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -212,6 +220,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan4B", "name": "System Board Fan4B",
"member_id": "0x17||Fan.Embedded.4B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -232,6 +241,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan5A", "name": "System Board Fan5A",
"member_id": "0x17||Fan.Embedded.5A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -252,6 +262,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan5B", "name": "System Board Fan5B",
"member_id": "0x17||Fan.Embedded.5B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -272,6 +283,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan6A", "name": "System Board Fan6A",
"member_id": "0x17||Fan.Embedded.6A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -292,6 +304,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan6B", "name": "System Board Fan6B",
"member_id": "0x17||Fan.Embedded.6B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -312,6 +325,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan7A", "name": "System Board Fan7A",
"member_id": "0x17||Fan.Embedded.7A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -332,6 +346,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan7B", "name": "System Board Fan7B",
"member_id": "0x17||Fan.Embedded.7B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -352,6 +367,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan8A", "name": "System Board Fan8A",
"member_id": "0x17||Fan.Embedded.8A",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -372,6 +388,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board Fan8B", "name": "System Board Fan8B",
"member_id": "0x17||Fan.Embedded.8B",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -392,6 +409,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "PS1 Status", "name": "PS1 Status",
"member_id": "PSU.Slot.1",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -413,6 +431,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board DIMM PG", "name": "System Board DIMM PG",
"member_id": "iDRAC.Embedded.1#SystemBoardDIMMPG",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -431,6 +450,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board NDC PG", "name": "System Board NDC PG",
"member_id": "iDRAC.Embedded.1#SystemBoardNDCPG",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -450,6 +470,7 @@ func TestDellApis(t *testing.T) {
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "System Board PS1 PG FAIL", "name": "System Board PS1 PG FAIL",
"member_id": "iDRAC.Embedded.1#SystemBoardPS1PGFAIL",
"address": address, "address": address,
"datacenter": "", "datacenter": "",
"health": "OK", "health": "OK",
@ -514,11 +535,12 @@ func TestHPApis(t *testing.T) {
testutil.MustMetric( testutil.MustMetric(
"redfish_thermal_temperatures", "redfish_thermal_temperatures",
map[string]string{ map[string]string{
"name": "01-Inlet Ambient", "name": "01-Inlet Ambient",
"source": "tpa-hostname", "member_id": "0",
"address": address, "source": "tpa-hostname",
"health": "OK", "address": address,
"state": "Enabled", "health": "OK",
"state": "Enabled",
}, },
map[string]interface{}{ map[string]interface{}{
"reading_celsius": 19.0, "reading_celsius": 19.0,
@ -530,11 +552,12 @@ func TestHPApis(t *testing.T) {
testutil.MustMetric( testutil.MustMetric(
"redfish_thermal_temperatures", "redfish_thermal_temperatures",
map[string]string{ map[string]string{
"name": "44-P/S 2 Zone", "name": "44-P/S 2 Zone",
"source": "tpa-hostname", "source": "tpa-hostname",
"address": address, "member_id": "42",
"health": "OK", "address": address,
"state": "Enabled", "health": "OK",
"state": "Enabled",
}, },
map[string]interface{}{ map[string]interface{}{
"reading_celsius": 34.0, "reading_celsius": 34.0,
@ -546,11 +569,12 @@ func TestHPApis(t *testing.T) {
testutil.MustMetric( testutil.MustMetric(
"redfish_thermal_fans", "redfish_thermal_fans",
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "Fan 1", "name": "Fan 1",
"address": address, "member_id": "0",
"health": "OK", "address": address,
"state": "Enabled", "health": "OK",
"state": "Enabled",
}, },
map[string]interface{}{ map[string]interface{}{
"reading_percent": 23, "reading_percent": 23,
@ -560,11 +584,12 @@ func TestHPApis(t *testing.T) {
testutil.MustMetric( testutil.MustMetric(
"redfish_thermal_fans", "redfish_thermal_fans",
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "Fan 2", "name": "Fan 2",
"address": address, "member_id": "1",
"health": "OK", "address": address,
"state": "Enabled", "health": "OK",
"state": "Enabled",
}, },
map[string]interface{}{ map[string]interface{}{
"reading_percent": 23, "reading_percent": 23,
@ -574,11 +599,12 @@ func TestHPApis(t *testing.T) {
testutil.MustMetric( testutil.MustMetric(
"redfish_thermal_fans", "redfish_thermal_fans",
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "Fan 3", "name": "Fan 3",
"address": address, "member_id": "2",
"health": "OK", "address": address,
"state": "Enabled", "health": "OK",
"state": "Enabled",
}, },
map[string]interface{}{ map[string]interface{}{
"reading_percent": 23, "reading_percent": 23,
@ -588,11 +614,12 @@ func TestHPApis(t *testing.T) {
testutil.MustMetric( testutil.MustMetric(
"redfish_power_powersupplies", "redfish_power_powersupplies",
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "HpeServerPowerSupply", "name": "HpeServerPowerSupply",
"address": address, "member_id": "0",
"health": "OK", "address": address,
"state": "Enabled", "health": "OK",
"state": "Enabled",
}, },
map[string]interface{}{ map[string]interface{}{
"power_capacity_watts": 800.0, "power_capacity_watts": 800.0,
@ -604,11 +631,12 @@ func TestHPApis(t *testing.T) {
testutil.MustMetric( testutil.MustMetric(
"redfish_power_powersupplies", "redfish_power_powersupplies",
map[string]string{ map[string]string{
"source": "tpa-hostname", "source": "tpa-hostname",
"name": "HpeServerPowerSupply", "name": "HpeServerPowerSupply",
"address": address, "member_id": "1",
"health": "OK", "address": address,
"state": "Enabled", "health": "OK",
"state": "Enabled",
}, },
map[string]interface{}{ map[string]interface{}{
"power_capacity_watts": 800.0, "power_capacity_watts": 800.0,
@ -670,9 +698,10 @@ func TestInvalidUsernameorPassword(t *testing.T) {
var acc testutil.Accumulator var acc testutil.Accumulator
r.Init() r.Init()
err := r.Gather(&acc) u, err := url.Parse(ts.URL)
require.Error(t, err) require.NoError(t, err)
require.EqualError(t, err, "received status code 401 (Unauthorized), expected 200") err = r.Gather(&acc)
require.EqualError(t, err, "received status code 401 (Unauthorized) for address http://"+u.Host+", expected 200")
} }
func TestNoUsernameorPasswordConfiguration(t *testing.T) { func TestNoUsernameorPasswordConfiguration(t *testing.T) {