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
- tags:
- source
- member_id
- address
- name
- datacenter (available only if location data is found)
@ -53,6 +54,7 @@ Telegraf minimum version: Telegraf 1.15.0
+ redfish_thermal_fans
- tags:
- source
- member_id
- address
- name
- datacenter (available only if location data is found)
@ -73,6 +75,7 @@ Telegraf minimum version: Telegraf 1.15.0
- tags:
- source
- address
- member_id
- name
- datacenter (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:
- source
- address
- member_id
- name
- datacenter (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
```
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=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=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=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_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=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=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_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=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_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,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=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_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,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,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,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,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,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,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,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,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,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,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,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,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 {
PowerSupplies []struct {
Name string
MemberId string
PowerInputWatts *float64
PowerCapacityWatts *float64
PowerOutputWatts *float64
@ -82,6 +83,7 @@ type Power struct {
}
Voltages []struct {
Name string
MemberId string
ReadingVolts *float64
UpperThresholdCritical *float64
UpperThresholdFatal *float64
@ -94,6 +96,7 @@ type Power struct {
type Thermal struct {
Fans []struct {
Name string
MemberId string
Reading *int64
ReadingUnits *string
UpperThresholdCritical *int64
@ -104,6 +107,7 @@ type Thermal struct {
}
Temperatures []struct {
Name string
MemberId string
ReadingCelsius *float64
UpperThresholdCritical *float64
UpperThresholdFatal *float64
@ -189,9 +193,10 @@ func (r *Redfish) getData(url string, payload interface{}) error {
defer resp.Body.Close()
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,
http.StatusText(resp.StatusCode))
http.StatusText(resp.StatusCode),
r.Address)
}
body, err := ioutil.ReadAll(resp.Body)
@ -271,6 +276,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range thermal.Temperatures {
tags := map[string]string{}
tags["member_id"] = j.MemberId
tags["address"] = address
tags["name"] = j.Name
tags["source"] = system.Hostname
@ -295,6 +301,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range thermal.Fans {
tags := map[string]string{}
fields := make(map[string]interface{})
tags["member_id"] = j.MemberId
tags["address"] = address
tags["name"] = j.Name
tags["source"] = system.Hostname
@ -326,6 +333,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range power.PowerSupplies {
tags := map[string]string{}
tags["member_id"] = j.MemberId
tags["address"] = address
tags["name"] = j.Name
tags["source"] = system.Hostname
@ -349,6 +357,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error {
for _, j := range power.Voltages {
tags := map[string]string{}
tags["member_id"] = j.MemberId
tags["address"] = address
tags["name"] = j.Name
tags["source"] = system.Hostname

View File

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